EECS 370 Discussion 1 xkcd.com. EECS 370 Discussion Topics Today: – ARM Addressing Endianness, Loading, and Storing Data – Data Layout Struct Packing.

Slides:



Advertisements
Similar presentations
Slides created by: Professor Ian G. Harris Efficient C Code  Your C program is not exactly what is executed  Machine code is specific to each ucontroller.
Advertisements

ARM versions ARM architecture has been extended over several versions.
Cosc 2150: Computer Organization
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Run-time Environment for a Program different logical parts of a program during execution stack – automatically allocated variables (local variables, subdivided.
F28PL1 Programming Languages Lecture 2: Assembly Language 1.
Machine/Assembler Language Putting It All Together Noah Mendelsohn Tufts University Web:
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 2 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
ARM Microprocessor “MIPS for the Masses”.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
Lecture 5: Decision and Control CS 2011 Fall 2014, Dr. Rozier.
Architecture of the 680XX Outline Goal Reading 680XX Family
Embedded Systems Programming ARM assembler. Creating a binary from assembler source arm=linux-as Assembler Test1.S arm-linux-ld Linker Arm-boot.o Executable.
COMP3221 lec14-decision-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 14: Making Decisions in C/Assembly Language – II.
Memory - Registers Instruction Sets
ARM programmer’s model and assembler Embedded Systems Programming.
COMP3221 lec07-numbers-III.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 7: Number Systems - III
What is an instruction set?
Data Representation and Alignment Topics Simple static allocation and alignment of basic types and data structures Policies Mechanisms.
The ARM Programmer’s Model
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Assembly Programming on the TI-89 Created By: Adrian Anderson Trevor Swanson.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 5 Unsigned integer and floating point.
Lecture 2: Basic Instructions CS 2011 Fall 2014, Dr. Rozier.
Machine-Level Programming 6 Structured Data Topics Structs Unions.
C programming or Fun with pointers Tutorial #2 CPSC 261.
Ithaca College 1 Machine-Level Programming VIII: Advanced Topics: alignment & Unions Comp 21000: Introduction to Computer Systems & Assembly Lang Systems.
Lecture 2: Basic Instructions EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014, Dr.
Natawut NupairojAssembly Language1 Memory and Stack.
CSCI 136 Lab 1: 135 Review.
Topic 7: Control Flow Instructions CSE 30: Computer Organization and Systems Programming Winter 2011 Prof. Ryan Kastner Dept. of Computer Science and Engineering.
1 Instruction memory is used to store a program Processor gets one instruction at a time It stores it locally (like) I0, I1 registers PC points to next.
Computer Architecture and Organization
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
Computer Architecture EKT 422
Computer Organization 1 Instruction Fetch and Execute.
COMPUTER ORGANISATION Sri.S.A.Hariprasad Sr.Lecturer R.V.C.E Bangalore.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
1 The Instruction Set Architecture September 27 th, 2007 By: Corbin Johnson CS 146.
F28HS2 Hardware-Software Interfaces Lecture 7: ARM Assembly Language 1.
Carnegie Mellon Midterm Review : Introduction to Computer Systems October 15, 2012 Instructor:
Address alignment When a word (4-bytes) is loaded or stored the memory address must be a multiple of four. This is called an alignment restriction. Addresses.
©2000 Addison Wesley Little- and big-endian memory organizations.
Lecture 6: Decision and Control CS 2011 Spring 2016, Dr. Rozier.
Big-Endians Little-Endians and Bi-Endians
Chapter 15: Higher Level Constructs
The Stack Chapter 5 Lecture notes for SPARC Architecture, Assembly Language Programming and C, Richard P. Paul by Anu G. Bourgeois.
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
Making Decisions and Writing Loops
COMP3221: Microprocessors and Embedded Systems
Machine-Level Programming 6 Structured Data
CS-401 Computer Architecture & Assembly Language Programming
NIOS ISA Advanced Topics
Architecture CH006.
Registers in the CPU Inside the CPU.
8085 MICROPROCESSOR 8085 CPU Registers and Status Flags S Z AC P C A B
University of Gujrat Department of Computer Science
Figure 2- 1: ARM Registers Data Size
Computer Instructions
March 2006 Saeid Nooshabadi
Overheads for Computers as Components 2nd ed.
Computer Architecture and System Programming Laboratory
Branch & Call Chapter 4 Sepehr Naimi
Computer Architecture and System Programming Laboratory
An Introduction to the ARM CORTEX M0+ Instructions
Presentation transcript:

EECS 370 Discussion 1 xkcd.com

EECS 370 Discussion Topics Today: – ARM Addressing Endianness, Loading, and Storing Data – Data Layout Struct Packing – Control Flow Branches and PSR (Program Status Register) – Conditional Assembly Predicated Assembly Instructions – C to ARM Translation 2

EECS 370 Discussion ARM Addressing 3

EECS 370 Discussion ARM Addressing Big-Endian means Big End First Most Significant Byte (MSB) at first address in memory In EECS370 we use Big-Endian Applies to Bytes only! 4

EECS 370 Discussion ARM Addressing Example: sub r1, r1, #0x2 strh r1, [r2, #0x0] ldrsb r2, [r2, #0x1] ldrh r1, [r0, #0x1002] 5

EECS 370 Discussion Data Layout Golden Rule Start address of a variable is aligned based on the variable’s type char – byte aligned short – halfword aligned int – word aligned pointer – word aligned double – two-word aligned 6 Structs - start aligned based on alignment of largest member - end padded to make overall size a multiple of largest member

EECS 370 Discussion Data Layout Example: char a; char* b; short c; double* d; struct { int e; char f[10]; } g; 7

EECS 370 Discussion Control Flow ARM Registers: 16 total registers R0 – R12: General Purpose R13: Stack Pointer R14: Link Register R15: Program Counter  Dangerous! 8

EECS 370 Discussion Control Flow Program Status Register (PSR): Flags set by various assembly instructions N – result is negative Z – result is zero C – result had a carry out of bit 31 V – result had an overflow 9

EECS 370 Discussion Control Flow Branch Condition Codes based on PSR eq EQual Z == 1 ne Not Equal Z == 0 ge Greater than/Equal N == V lt Less Than N != V gt Greater Than Z == 0 && N == V le Less than/Equal Z == 1 || N != V cs unsigned higher/Same C == 1 cc unsigned lower C == 0 mi negative N == 1 pl positive/Zero N == 0 vs oVerflow Set V == 1 vc no oVerflow Clear V == 0 hi unsigned HIgher C == 1 && Z == 0 ls unsigned Lower/Same C == 0 || Z == 1 al any/Always 10

EECS 370 Discussion Conditional Assembly Condition Codes can also be applied to other instructions Example:Translate the following code while (r0 != 0) { if (r0 > 0) { r0 = r0 – 1; } else { r0 = r0 + 1; } 11

EECS 370 Discussion C to ARM Translation Do some examples. How to move 32-bit values into registers. 12