NET3001. Advanced Assembly

Size: px
Start display at page:

Download "NET3001. Advanced Assembly"

Transcription

1 NET3001 Advanced Assembly

2 Arrays and Indexing supposed we have an array of 16 bytes at 0x write a program that determines if the array contains the byte '0x12' set r0=1 if the byte is found plan: set r0=0... not found load r6 with 0 and count up to 16 load r7 with 0x at each point, get the byte at [0x r6] and compare it to 0x12 if it matches, set r0=0 and exit

3 Search for a Byte in C char recs[16]; // 0x8100 int i; // r6 int r0 = 0; for (i=0; i<16; i++) if (recs[i]==0x12) { r0 = 1; break; } // check for a match

4 Search for a Byte in asm.text.word 0x , _start.global main, _start.type _start,%function _start: main: mov r0, #0 ; set r0 = not found mov r6, #0 ; r6 is i, set to 0 ldr r7, =recs again: ldrb r1, [r7, r6] ; fetch cmp r1, #0x12 ; and test beq found_one add r6, #1 ; i++ cmp r6, #16 ; i<16 blo again ; repeat b done found_one: mov r0, #1 ; change r0 to found done: b done ; we're finished recs:.byte 1,2,3,1,2,3,0x10,0x12,4,3,2,1,5,6,7,8 NOTE: an alternate version uses ldrb r1, [r7], #1 // increment after

5 Search for a Byte Name Value Type Size Content _start 0x label;func 0 main 0x label 0 again 0x label 0 found_one 0x label 0 done 0x label recs 0x byte[] 16 1,2,3...

6 Search for a Byte.2 change the previous problem so that the address of the array is passed in R0, the search pattern is passed in R1 this is to prepare for turning it into a subroutine

7 Search for a Byte.text.word 0x , main.global main main: mov r3, #0 ; set r3 = not found mov r6, #0 ; r6 is i, set to 0 again: ldrb r2, [r0, r6] ; fetch cmp r2, r1 ; test beq found_one add r6, r6, #1 ; i++ cmp r6, #16 ; i<16 jlo again ; repeat jmp done found_one: mov r3, #1 ; set r3 = found done: jmp done.org 0x100 recs.byte 1,2,3,1,2,3,0x10,0x12,4,3,2,1,5,6,7,8

8 Testing and Branching in C code, we often need this if (r0<10) r0++; else r0 = 0; the assembly language equivalent would be cmp r0,#10 // sets the N,C,V,Z bits bge s1 // branch for 10 or more add r0,r0,#1 // do the <10 stuff b s2 // and jump over the else s1: mov r0,#0 // do the else s2: // and carry on on this slide, we treat r0 as signed

9 Branching in ARM, you have the following branches available to you: b branch (always) bcc/blo bcs/bhs bhi bls for unsigned numbers bgt bge blt ble bvs bvc beq bne bmi bpl bcs is the same as bhs bcc is the same as blo...use either for signed numbers almost never used; uses V bit equality; beq is the same as bz minus and plus; uses the N bit cbz cbnz you can check a reg and branch e.g. cbnz r0,loop_again* bl bx lr *limited use: reg must be r0...r7; can only jump fwd branch and link; call subroutine return from subroutine

10 Testing and Branching in C code, we often need this for (r0=0; r0<10; r0++) { show7seg(r0); delayonesec(); } the assembly language equivalent would be mov r0,#0 // start the for loop loopit: push {r0} // save it, the sub's may modify it bl show7seg // 2 subroutines bl delayonesec pop {r0} // get r0 back add r0,r0,#1 // r0++ cmp r0,#10 // sets the N,C,V,Z bits blo s1 // branch back for less than10 // and carry on on this page, we treat r0 as unsigned

11 Stack an area of RAM is put aside to hold an array of words with the call and ret instruction, we can implement subroutines stack data 0x2000.1FFC 0x2000.1FF8 0x2000.1FF4 0x2000.1FF0... bottom of stack available available sp = r13 0x2000.1FF8 points to the bottom of the stack [r13] points at valid data, aka bottom of stack [r13,#-2] points to next empty location

12 Stack to put data on the stack: push a register push {r?} which does the following sub r13, #4 easiest then store register into [r13] same as STR r?, [r13,#-4]! // subtract before to recover it pop into a register pop {r?} which does this LDR r?, [r13] add r13,#4 same as LDR r?, [r13], #4 // add after if you want to discard stack data add r13, #n ; n should be a multiple of 4

13 Multiple Registers on Stack ARM and Cortex-M3 allow us to save and restore multiple registers examples push {r0, r1, r2, r14} pop {r0, r1, r2, r14} r14 is pushed first, then r0 is pushed last during the pop, the opposite order is used: r0 is popped first, finally popping r14 note that you don't need to use the same register names on the pop pop {r0, r1, r2, pc} what does this do?

14 Subroutines the call instruction is used to invoke a subroutine call somewhere effectively mov r14, r15 mov r15, somewhere the next instruction comes from the new location the return address is in r14 (Link Reg) r15 is constantly being incremented; the r15 that is copied into r14 is already pointing ahead to the next instruction the ret instruction is just mov r15,r14

15 Subroutines using bl/lr/pc the call instruction is used to invoke a subroutine bl somewhere // branch and link effectively mov lr, pc mov pc, somewhere the next instruction comes from the new location the return address is on the stack the ret instruction is just MOV pc,lr or BX LR

16 Subroutines registers ram registers ram r15 r14 r ?? F4 0x FC 0x F8 0x F4 0x F0 0x EC 0x E9... in use in use in use free free free... r15 r14 r F4 0x FC 0x F8 0x F4 0x F0 0x EC 0x E9... in use in use in use free free free... 0x x call (bl) add r5,#1 0x x call (bl) add r5,#1

17 Subroutines registers ram registers ram r15 r14 r F4 0x FC 0x F8 0x F4 0x F0 0x EC 0x E9... in use in use in use free free free... r15 r14 r F0 0x FC 0x F8 0x F4 0x F0 0x EC 0x E9... in use in use in use free free... 0x push {lr} 0x push {lr} 0x mov r0,#3 0x mov r0,#3

18 Stack Usage in our projects, start the stack at 0x stack is used to hold registers that must be preserved over subroutine call subroutine return address usually temporary variables used in the subroutine

19 Stack Usage the caller preps the arguments in r0..r3 the caller calls the subroutine the subroutine makes space for the temp (local) variables on the stack in C // caller a=12; b='x'; c = dosomething(a,b); // subroutine int dosomething(int a, int b) { int d,e; d = a+b; e = a+d; return e; }

20 Stack Usage in asm // caller mov r0, #12 // put the number 12 on stack mov r1, #'X' // put the 'X' on the stack call #dosomething // puts the return addr on stk // in the subroutine sub sp, #8 // make room on the stack // a is in r0, b is in r1 add r2,r1,r0 // d = a+b str r2,[sp,#0] add r2,r2,r0 // e = d+a str r2,[sp,#4] ldr r0,[sp,#4] // prepare to return bx lr // same as mov pc, lr

21 Arguments, Locals & Return arguments are passed to routines by pushing values onto the stack above the frame pointer (the return address) by setting them into registers local variables can be created on the stack below the frame pointer can use registers return value passed back in a register ARM eabi arguments, locals and the return value must not be in global variables!!!

22 Subroutines (using registers) the C compiler uses registers in this manner information is passed into the subroutine in r0, r1, r2 and r3 if it needs more than 4 words, it puts the extra on the stack the return value is in r0 if it needs more than a word, it uses r0 and r1 r0, r1, r2, r3, r12 may be destroyed r4...r11 are preserved a statement like this is called the Application Binary Interface, ABI

23 Nested Subroutines in C int mult(int a, int b) { int c = 0; while (b--) c+=a; return c; } int pythag(int x, int y) { int z = mult(y,y) + mult(x,x); return z; } // caller int g=4, h=7; h = pythag(g,h);

24 Nested Subroutines in ASM /* int mult (int a, int b) multiply 2 small +ve numbers arguments passed in r0 & r1 c is r2 (destroyed) mult: mov r2, #0 mult_again: cmp r1, #0 return value in r0 */ // a is in r0, b is in r1 // while (b) beq mult_done sub r1,r1,#1 // b-- add r2, r2, r0 // c += a b mult_again mult_done: mov r0, r2 bx lr // return

25 Nested Subroutines in ASM (another version) /* int mult (int a, int b) multiply 2 small +ve numbers arguments passed in r0, r1 r4 is used as 'c' (r4 preserved) return value in r0 */ mult: // a is in r0, b is in r1 push {r4} // save r4 mov r4, #0 mult_again: cmp r1, #0 // while (b) jeq mult_done sub r1, r1, #1 // b-- add r4, r4, r0 // c += a b mult_again mult_done: mov r0, r4 pop {r4} bx lr // return

26 Nested Subroutines in ASM /* int pythag(int x, int y) return the sum of squares arguments passed in r0, r1 return value in r0 local z is on the stack; r2 is destroyed */ pythag: push {r0, r1, lr} // save x, y and return address sub sp,sp,#4 // make room for z // prepare to call subroutine "mult" mov r1, r0 // make both the same as x bl mult // mult(x,x) answer comes back in r0 str r0,[sp] // answer goes into z on stack ldr r0,[sp,#8] // get a copy of y // prepare to call "mult" again mov r1, r0 // both are copies of y bl mult // mult(y,y) answer comes back in r0 ldr r1,[sp] // get z back from the stack add r0, r0, r1 // sum is in r0 add sp,sp,#12 // throw away z and y and x pop {pc} // use the return address and go back

27 in ASM // main code.data g:.word 4 h:.word 7 result:.word 0 Nested Subroutines.text ldr r2, =g ldr r0, [r2] ldr r2, =h ldr r1, [r2] bl pythag // return value is in r0 ldr r2, =result str r0, [r2]

28 Frame Pointer inside a subroutine, it's a common technique to use a register (r7) to hold a stationary pointer to the stack as you push and pop data, r13/sp is constantly changing it's easier to use r7 as a basis to fetch variables naturally, if all subroutines use r7, it's important to save-and-restore r7 ; at entry push {r7, lr} ; at exit pop {r7, pc} // does an implicit return on a Pentium, we use ebp (extended base pointer)

29 Frame Pointer common usage suppose we have a subroutine like this int fancyprint(char* fmt, int ndigits, char decimal) { int a, b, c, d, e;...then the code... on the way into the subroutine push {r7, lr} // save both sub sp, #32 // make room for 8 words add r7,sp,#20 // then r7 is pointing midway up // there are 3 words above r7 and 5 words below the 3 above the line will be fmt, ndigits, and decimal the 5 below the line will be a,b,c,d,e

30 Frame Pointer at the end, we can use r7 to restore the sp ; at exit add sp, r7, #12 pop {r7, pc} // returns frame pointer is only commonly used when you're debugging final code for shipment often doesn't use frame pointer

31 Stack Usage with Frame Pointer ram ram ram FC F F F EC sp= FC old stack FC F F F EC sp= E8 old stack lr (ret addr) r7 4 = x = copy g 7 = y = copy h z (unknown) FC F F F EC sp= D4 old stack lr (ret addr) r7 4 7 z ret addr r7 4 = a = copy x 4 = b = copy x c (unknown) = h 4 = g = h 4 = g = h 4 =g

32 Stack Usage with Frame Pointer ram ram ram FC F F F EC sp= D4 old stack lr (ret addr) r =z ret addr r7 7 = a = copy y 7 = b = copy y c (unknown) FC F F F EC sp= E8 old stack lr (ret addr) r7 4 = x = copy g 7 = y = copy h 65 = z FC F F F EC sp= FC old stack = h 4 = g = h 4 = g = result 7 = h 4 = g

33 Nested Subroutines (using FP) in ASM /* int mult (int a, int b) multiply 2 small +ve numbers arguments passed r0=a, r0=b return value in r0 */ mult: // a is r0, b is r1 push {r7, lr} sub sp,#12 // room for a,b,c add r7,sp,#4 // pointing at b str r0,[sp,#8] // save a (could use [r7,#4]) str r1,[sp,#4] // save b (could use [r7]) mov r2, #0 // initialize c mult_again: cmp r1, #0 // while (b) beq mult_done sub r1, #1 // b-- add r2, r2, r0 // c += a b mult_again mult_done: mov r0, r2 // the answer add sp,r7,#8 // move stack to where it started pop {r7,pc} // return

34 Nested Subroutines (using FP) in ASM /* int pythag(int x, int y) using frame pointer return the sum of squares arguments passed in on r0=x, r1=y return value in r0 */ pythag: push {r0, r1, r7, lr} // save x, y, fp and return address sub sp, #4 // make room for z add r7, sp, #4 // r7 points at y = [sp,#4] // z is at [r7,#-4] mov r1, r0 // do x first bl mult // x is already in r0, where we want it str r0, [r7,#-4] // save the result into z ldr r0, [r7] // fetch y from ram mov r1, r0 bl mult ldr r1, [r7,#-4] // recall z from ram add r0, r0, r1 // and add them...ready to return add sp, r7, #8 // put the stack back; throw away x,y pop {r7, pc} // and return

35 Nested Subroutines (using FP) in ASM...no change // main code.data g:.word 4 h:.word 7 result:.word 0.text ldr r2, =g ldr r0, [r2] ldr r2, =h ldr r1, [r2] bl pythag // return value is in r0 ldr r2, =result str r0, [r2]

36 there is less requirement for the above now that we have a proper EABI Subroutines in ASM are only complete if they include these comments: use a C prototype required! describe the arguments passed in and how they are passed the how is now optional describe the return value and how it is passed back the how is now optional list registers are affected optional

37 Stack Operations the operations on the stack can be described in terms of the basic machine instructions turns into push {r6, r8} sub sp, sp, #8 str r8, [sp, #4] str r6, [sp] // same as stmdb sp!,{r6,r8} // move the stack pointer down // save the data on the stack turns into pop {r9} ldr r9, [sp] // same as ldmia sp!,{r9} // get the data from the stack add sp, sp, #4 // move the stack pointer up or, more simply ldr r9, [sp], #4 // use indirect post increment

38 Stack Operations (cont'd) turns into bl dosomething // calling subroutine mov lr, pc // r14 <- r15 save the return address add pc, pc, #distance_to_dosomething // jump by stuffing r15 bx lr turns into mov pc, lr // return from subroutine //restore the return address

39 Stack Operations (cont'd) when an interrupt happens, the cpu does this: push {r0,r1,r2,r3,r12,lr,pc,psr} movw lr,#0xfffffff9 ldr pc,[vector_table_entry] at the end of interrupt bx lr // return from interrupt turns into // putting FFFF.FFF9 into PC is invalid, // so the CPU knows it's returning from // interrupt pop {r0,r1,r2,r3,r12,lr,pc,psr} // so we return to interrupted program

40 What is the EABI extended applications binary interface registers r4...r11 are preserved by subroutines arguments are passed to subroutines in r0,r1,r2,r3 return value from a subroutine is sent back in r0 r0/1/2/3 & r12 can be modified at any time stack on the way into subroutines is 8 byte aligned (ends in 3 0's) If you have nested subroutines, you will need to manage your r0,r1 data carefully!

41 Binary Operations: AND to extract only certain bits from a field AND the data with a bit mask with 1's where you want to keep the data for example, to extract bits 1 & 2, you can AND with the pattern #0x06 ( ) AND r0, r0, #0x06 in C, result = data & 0x06; to force certain bits to go low AND the data with the bit mask with 0's where you want to force a 0 for example, to force 0's into bits 5 & 6, you can AND with the pattern 0x9F ( ) in C, result = data & 0x9F; or result = data & ~0x60;

42 Binary Operations: OR, XOR to force certain bits high OR the data with a bit mask containing 1's where you want to force the bits up for example, to force bits 4 & 5 to be set high, you can OR the data with #0x30 ( ) in C, result = data 0x30; to force certain bits to change XOR the data with a bit mask containing 1's where you want the data to change for example, to force bit 0 to change, XOR the data with #0x01 ( ) in C, result = data ^ 1;

43 and r7, r7, #0xFFFFFFF8 bic r7, r7, #0x07 // does the same Binary Operations: Cortex special ops on the Cortex CPU the ORR operation just performs the OR the ORRS operation also sets the status bits: N,Z,C the OR operation is also known as bit-set BIS on some CPUs the AND operation just performs the AND the ANDS operation also sets the status bits: N,Z,C the TST operation only sets the status bits: N,Z,C does the same as AND, but doesn't save the result there is also the BIC to force certain bits low the setting argument includes the bits that you want to set low this is the opposite of the pattern you would use with an AND instruction there is also the BICS operation which sets the status bits

44 Binary Operations: Summary isolating bits force bits low force bits high change bits AND TST AND BIC ORR EOR save result does not modify status discard result modify status save result does not modify status save result do not modify status uses inverted pattern save result do not modify status save result does not modify status

ARM Assembly Language. Programming

ARM Assembly Language. Programming Outline: ARM Assembly Language the ARM instruction set writing simple programs examples Programming hands-on: writing simple ARM assembly programs 2005 PEVE IT Unit ARM System Design ARM assembly language

More information

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls

CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls CprE 288 Introduction to Embedded Systems ARM Assembly Programming: Translating C Control Statements and Function Calls Instructors: Dr. Phillip Jones 1 Announcements Final Projects Projects: Mandatory

More information

EE319K Fall 2013 Exam 1B Modified Page 1. Exam 1. Date: October 3, 2013

EE319K Fall 2013 Exam 1B Modified Page 1. Exam 1. Date: October 3, 2013 EE319K Fall 2013 Exam 1B Modified Page 1 Exam 1 Date: October 3, 2013 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will

More information

(2) Part a) Registers (e.g., R0, R1, themselves). other Registers do not exists at any address in the memory map

(2) Part a) Registers (e.g., R0, R1, themselves). other Registers do not exists at any address in the memory map (14) Question 1. For each of the following components, decide where to place it within the memory map of the microcontroller. Multiple choice select: RAM, ROM, or other. Select other if the component is

More information

ARM Instruction Set Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

ARM Instruction Set Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University ARM Instruction Set Architecture Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Condition Field (1) Most ARM instructions can be conditionally

More information

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones

CprE 288 Introduction to Embedded Systems Course Review for Exam 3. Instructors: Dr. Phillip Jones CprE 288 Introduction to Embedded Systems Course Review for Exam 3 Instructors: Dr. Phillip Jones 1 Announcements Exam 3: See course website for day/time. Exam 3 location: Our regular classroom Allowed

More information

EE319K Spring 2015 Exam 1 Page 1. Exam 1. Date: Feb 26, 2015

EE319K Spring 2015 Exam 1 Page 1. Exam 1. Date: Feb 26, 2015 EE319K Spring 2015 Exam 1 Page 1 Exam 1 Date: Feb 26, 2015 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help

More information

Exam 1. Date: Oct 4, 2018

Exam 1. Date: Oct 4, 2018 Exam 1 Date: Oct 4, 2018 UT EID: Professor: Valvano Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help others to cheat

More information

EE319K Spring 2016 Exam 1 Solution Page 1. Exam 1. Date: Feb 25, UT EID: Solution Professor (circle): Janapa Reddi, Tiwari, Valvano, Yerraballi

EE319K Spring 2016 Exam 1 Solution Page 1. Exam 1. Date: Feb 25, UT EID: Solution Professor (circle): Janapa Reddi, Tiwari, Valvano, Yerraballi EE319K Spring 2016 Exam 1 Solution Page 1 Exam 1 Date: Feb 25, 2016 UT EID: Solution Professor (circle): Janapa Reddi, Tiwari, Valvano, Yerraballi Printed Name: Last, First Your signature is your promise

More information

Cortex M3 Programming

Cortex M3 Programming Cortex M3 Programming EE8205: Embedded Computer Systems http://www.ee.ryerson.ca/~courses/ee8205/ Dr. Gul N. Khan http://www.ee.ryerson.ca/~gnkhan Electrical and Computer Engineering Ryerson University

More information

Architecture. Digital Computer Design

Architecture. Digital Computer Design Architecture Digital Computer Design Architecture The architecture is the programmer s view of a computer. It is defined by the instruction set (language) and operand locations (registers and memory).

More information

Exam 1 Fun Times. EE319K Fall 2012 Exam 1A Modified Page 1. Date: October 5, Printed Name:

Exam 1 Fun Times. EE319K Fall 2012 Exam 1A Modified Page 1. Date: October 5, Printed Name: EE319K Fall 2012 Exam 1A Modified Page 1 Exam 1 Fun Times Date: October 5, 2012 Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will

More information

EE319K Exam 1 Summer 2014 Page 1. Exam 1. Date: July 9, Printed Name:

EE319K Exam 1 Summer 2014 Page 1. Exam 1. Date: July 9, Printed Name: EE319K Exam 1 Summer 2014 Page 1 Exam 1 Date: July 9, 2014 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help

More information

Assembly Language Programming

Assembly Language Programming Assembly Language Programming ECE 362 https://engineering.purdue.edu/ee362/ Rick Reading and writing arrays Consider this C code again: int array1[100]; int array2[100]; for(n=0; n

More information

ECE251: Tuesday September 18

ECE251: Tuesday September 18 ECE251: Tuesday September 18 Subroutine Parameter Passing (Important) Allocating Memory in Subroutines (Important) Recursive Subroutines (Good to know) Debugging Hints Programming Hints Preview of I/O

More information

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming Assembly Programming HCS12 Assembly Programming Basic Assembly Programming Top Assembly Instructions (Instruction You Should Know!) Assembly Programming Concepts Assembly Programming HCS12 Assembly Instructions

More information

Outline. ARM Introduction & Instruction Set Architecture. ARM History. ARM s visible registers

Outline. ARM Introduction & Instruction Set Architecture. ARM History. ARM s visible registers Outline ARM Introduction & Instruction Set Architecture Aleksandar Milenkovic E-mail: Web: milenka@ece.uah.edu http://www.ece.uah.edu/~milenka ARM Architecture ARM Organization and Implementation ARM Instruction

More information

ARM Assembly Programming

ARM Assembly Programming Introduction ARM Assembly Programming The ARM processor is very easy to program at the assembly level. (It is a RISC) We will learn ARM assembly programming at the user level and run it on a GBA emulator.

More information

Introduction to Embedded Systems EE319K (Gerstlauer), Spring 2013

Introduction to Embedded Systems EE319K (Gerstlauer), Spring 2013 The University of Texas at Austin Department of Electrical and Computer Engineering Introduction to Embedded Systems EE319K (Gerstlauer), Spring 2013 Midterm 1 Solutions Date: February 21, 2013 UT EID:

More information

ARM Cortex-M4 Programming Model Flow Control Instructions

ARM Cortex-M4 Programming Model Flow Control Instructions ARM Cortex-M4 Programming Model Flow Control Instructions Textbook: Chapter 4, Section 4.9 (CMP, TEQ,TST) Chapter 6 ARM Cortex-M Users Manual, Chapter 3 1 CPU instruction types Data movement operations

More information

Systems Architecture The Stack and Subroutines

Systems Architecture The Stack and Subroutines Systems Architecture The Stack and Subroutines The Stack p. 1/9 The Subroutine Allow re-use of code Write (and debug) code once, use it many times A subroutine is called Subroutine will return on completion

More information

ECE251: Tuesday September 12

ECE251: Tuesday September 12 ECE251: Tuesday September 12 Finish Branch related instructions Stack Subroutines Note: Lab 3 is a 2 week lab, starting this week and covers the Stack and Subroutines. Labs: Lab #2 is due this week. Lab

More information

ARM Cortex M3 Instruction Set Architecture. Gary J. Minden March 29, 2016

ARM Cortex M3 Instruction Set Architecture. Gary J. Minden March 29, 2016 ARM Cortex M3 Instruction Set Architecture Gary J. Minden March 29, 2016 1 Calculator Exercise Calculate: X = (45 * 32 + 7) / (65 2 * 18) G. J. Minden 2014 2 Instruction Set Architecture (ISA) ISAs define

More information

Support for high-level languages

Support for high-level languages Outline: Support for high-level languages memory organization ARM data types conditional statements & loop structures the ARM Procedure Call Standard hands-on: writing & debugging C programs 2005 PEVE

More information

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2016 1 ISA is the HW/SW

More information

Interrupt-Driven Input/Output

Interrupt-Driven Input/Output Interrupt-Driven Input/Output Textbook: Chapter 11 (Interrupts) ARM Cortex-M4 User Guide (Interrupts, exceptions, NVIC) Sections 2.1.4, 2.3 Exceptions and interrupts Section 4.2 Nested Vectored Interrupt

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-09 In Class Example Handout Part A: A Simple, MIPS-based Procedure: Swap Procedure Example: Let s write the MIPS code for the following statement (and function call): if (A[i] > A

More information

CMPSCI 201 Fall 2005 Midterm #2 Solution

CMPSCI 201 Fall 2005 Midterm #2 Solution CMPSCI 201 Fall 2005 Midterm #2 Solution Professor William T. Verts 10 Points Convert the decimal number -47.375 into (a) binary scientific notation (i.e., ±1.xxxx 2 Y ), and (b) the equivalent binary

More information

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

An Introduction to Assembly Programming with the ARM 32-bit Processor Family An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2

More information

Exam 1. Date: February 23, 2016

Exam 1. Date: February 23, 2016 Exam 1 Date: February 23, 2016 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help others to cheat on this exam:

More information

ECE251: Tuesday September 11

ECE251: Tuesday September 11 ECE251: Tuesday September 11 Finish Branch related instructions Stack Subroutines Note: Lab 3 is a 2 week lab, starting this week and covers the Stack and Subroutines. Labs: Lab #2 is due this week. Lab

More information

Programming the Motorola MC68HC11 Microcontroller

Programming the Motorola MC68HC11 Microcontroller Programming the Motorola MC68HC11 Microcontroller COMMON PROGRAM INSTRUCTIONS WITH EXAMPLES aba Add register B to register A Similar commands are abx aby aba add the value in register B to the value in

More information

ARM Assembly Programming II

ARM Assembly Programming II ARM Assembly Programming II Computer Organization and Assembly Languages Yung-Yu Chuang 2007/11/26 with slides by Peng-Sheng Chen GNU compiler and binutils HAM uses GNU compiler and binutils gcc: GNU C

More information

ARM Assembly Programming

ARM Assembly Programming ARM Assembly Programming Computer Organization and Assembly Languages g Yung-Yu Chuang 2007/12/1 with slides by Peng-Sheng Chen GNU compiler and binutils HAM uses GNU compiler and binutils gcc: GNU C compiler

More information

ECE 471 Embedded Systems Lecture 5

ECE 471 Embedded Systems Lecture 5 ECE 471 Embedded Systems Lecture 5 Vince Weaver http://www.eece.maine.edu/ vweaver vincent.weaver@maine.edu 17 September 2013 HW#1 is due Thursday Announcements For next class, at least skim book Chapter

More information

Exam 1. Date: February 23, 2018

Exam 1. Date: February 23, 2018 Exam 1 Date: February 23, 2018 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help others to cheat on this exam:

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications Lecture Overview EE 3170 Microcontroller Applications Lecture 7 : Instruction Subset & Machine Language: Conditions & Branches in Motorola 68HC11 - Miller 2.2 & 2.3 & 2.4 Based on slides for ECE3170 by

More information

ECE 498 Linux Assembly Language Lecture 5

ECE 498 Linux Assembly Language Lecture 5 ECE 498 Linux Assembly Language Lecture 5 Vince Weaver http://www.eece.maine.edu/ vweaver vincent.weaver@maine.edu 29 November 2012 Clarifications from Lecture 4 What is the Q saturate status bit? Some

More information

ARM Assembly Programming

ARM Assembly Programming ARM Assembly Programming Computer Organization and Assembly Languages g Yung-Yu Chuang with slides by Peng-Sheng Chen GNU compiler and binutils HAM uses GNU compiler and binutils gcc: GNU C compiler as:

More information

button.c The little button that wouldn t

button.c The little button that wouldn t Goals for today The little button that wouldn't :( the volatile keyword Pointer operations => ARM addressing modes Implementation of C function calls Management of runtime stack, register use button.c

More information

Introduction to C. Write a main() function that swaps the contents of two integer variables x and y.

Introduction to C. Write a main() function that swaps the contents of two integer variables x and y. Introduction to C Write a main() function that swaps the contents of two integer variables x and y. void main(void){ int a = 10; int b = 20; a = b; b = a; } 1 Introduction to C Write a main() function

More information

F28HS Hardware-Software Interface. Lecture 10: ARM Assembly Language 5

F28HS Hardware-Software Interface. Lecture 10: ARM Assembly Language 5 F28HS Hardware-Software Interface Lecture 10: ARM Assembly Language 5 Software interrupt SWI operand operand is interrupt number halts program saves PC branches to interrupt service code corresponding

More information

EE445M/EE380L.6 Quiz 2 Spring 2017 Solution Page 1 of 5

EE445M/EE380L.6 Quiz 2 Spring 2017 Solution Page 1 of 5 EE445M/EE380L.6 Quiz 2 Spring 2017 Solution Page 1 of 5 First Name: Last Name: April 21, 2017, 10:00 to 10:50am Open book, open notes, calculator (no laptops, phones, devices with screens larger than a

More information

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009 Topic Notes: MIPS Programming We spent some time looking at the MIPS Instruction Set Architecture. We will now consider

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 4: Logic Operations and Introduction to Conditionals Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Previously examined

More information

EEM870 Embedded System and Experiment Lecture 4: ARM Instruction Sets

EEM870 Embedded System and Experiment Lecture 4: ARM Instruction Sets EEM870 Embedded System and Experiment Lecture 4 ARM Instruction Sets Wen-Yen Lin, Ph.D. Department of Electrical Engineering Chang Gung University Email wylin@mail.cgu.edu.tw March 2014 Introduction Embedded

More information

ECE 471 Embedded Systems Lecture 8

ECE 471 Embedded Systems Lecture 8 ECE 471 Embedded Systems Lecture 8 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 21 September 2018 Announcements HW#2 was due HW#3 will be posted today. Work in groups? Note

More information

Implementing Functions at the Machine Level

Implementing Functions at the Machine Level Subroutines/Functions Implementing Functions at the Machine Level A subroutine is a program fragment that... Resides in user space (i.e, not in OS) Performs a well-defined task Is invoked (called) by a

More information

ECE251: Intro to Microprocessors Name: Solutions Mid Term Exam October 4, 2018

ECE251: Intro to Microprocessors Name: Solutions Mid Term Exam October 4, 2018 ECE251: Intro to Microprocessors Name: Solutions Mid Term Exam October 4, 2018 (PRINT) Instructions: No calculators, books, or cell phones; do not communicate with any other student. One side of a single

More information

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015 Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative

More information

EE319K (Gerstlauer), Spring 2013, Midterm 1 1. Midterm 1. Date: February 21, 2013

EE319K (Gerstlauer), Spring 2013, Midterm 1 1. Midterm 1. Date: February 21, 2013 EE319K (Gerstlauer), Spring 2013, Midterm 1 1 Midterm 1 Date: February 21, 2013 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam,

More information

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1 CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB

More information

Subroutines and the Stack

Subroutines and the Stack 3 31 Objectives: A subroutine is a reusable program module A main program can call or jump to the subroutine one or more times The stack is used in several ways when subroutines are called In this lab

More information

Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University. See P&H 2.8 and 2.12, and A.

Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University. See P&H 2.8 and 2.12, and A. Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See P&H 2.8 and 2.12, and A.5 6 compute jump/branch targets memory PC +4 new pc Instruction Fetch

More information

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture COMP 303 Computer Architecture Lecture 3 Comp 303 Computer Architecture 1 Supporting procedures in computer hardware The execution of a procedure Place parameters in a place where the procedure can access

More information

Computer Organization & Assembly Language Programming (CSE 2312)

Computer Organization & Assembly Language Programming (CSE 2312) Computer Organization & Assembly Language Programming (CSE 2312) Lecture 16: Processor Pipeline Introduction and Debugging with GDB Taylor Johnson Announcements and Outline Homework 5 due today Know how

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization CISC 662 Graduate Computer Architecture Lecture 4 - ISA MIPS ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

CMPSCI 201 Fall 2006 Midterm #2 November 20, 2006 SOLUTION KEY

CMPSCI 201 Fall 2006 Midterm #2 November 20, 2006 SOLUTION KEY CMPSCI 201 Fall 2006 Midterm #2 November 20, 2006 SOLUTION KEY Professor William T. Verts 10 Points Trace the following circuit, called a demultiplexer, and show its outputs for all possible inputs.

More information

ARM Cortex-A9 ARM v7-a. A programmer s perspective Part 2

ARM Cortex-A9 ARM v7-a. A programmer s perspective Part 2 ARM Cortex-A9 ARM v7-a A programmer s perspective Part 2 ARM Instructions General Format Inst Rd, Rn, Rm, Rs Inst Rd, Rn, #0ximm 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7

More information

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture) COSC 243 Instruction Sets And Addressing Modes 1 Overview This Lecture Source Chapters 12 & 13 (10 th editition) Textbook uses x86 and ARM (we use 6502) Next 2 Lectures Assembly language programming 2

More information

MIPS Functions and the Runtime Stack

MIPS Functions and the Runtime Stack MIPS Functions and the Runtime Stack COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

ARM Assembly Language

ARM Assembly Language ARM Assembly Language Introduction to ARM Basic Instruction Set Microprocessors and Microcontrollers Course Isfahan University of Technology, Dec. 2010 1 Main References The ARM Architecture Presentation

More information

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

ECE331 Handout 3- ASM Instructions, Address Modes and Directives ECE331 Handout 3- ASM Instructions, Address Modes and Directives ASM Instructions Functional Instruction Groups Data Transfer/Manipulation Arithmetic Logic & Bit Operations Data Test Branch Function Call

More information

Computer System Architecture

Computer System Architecture CSC 203 1.5 Computer System Architecture Department of Statistics and Computer Science University of Sri Jayewardenepura Addressing 2 Addressing Subject of specifying where the operands (addresses) are

More information

Exam 1. Date: February 23, 2018

Exam 1. Date: February 23, 2018 Exam 1 Date: February 23, 2018 UT EID: Printed Name: Last, First Your signature is your promise that you have not cheated and will not cheat on this exam, nor will you help others to cheat on this exam:

More information

Introduction to Embedded Microcomputer Systems Lecture 8.1. Computers in the future may weigh no more than 1.5 tons Popular Science, 1949

Introduction to Embedded Microcomputer Systems Lecture 8.1. Computers in the future may weigh no more than 1.5 tons Popular Science, 1949 Introduction to Embedded Microcomputer Systems Lecture 8.1 Computers in the future may weigh no more than 1.5 tons Popular Science, 1949 Recap Debugging: Monitor, dump TExaS Real 9S12DG Overview Addition

More information

CS 61C: Great Ideas in Computer Architecture More RISC-V Instructions and How to Implement Functions

CS 61C: Great Ideas in Computer Architecture More RISC-V Instructions and How to Implement Functions CS 61C: Great Ideas in Computer Architecture More RISC-V Instructions and How to Implement Functions Instructors: Krste Asanović and Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c/fa17 9/14/17 Fall

More information

CENG3420 Lecture 03 Review

CENG3420 Lecture 03 Review CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less

More information

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture ECE468 Computer Organization & Architecture MIPS Instruction Set Architecture ECE468 Lec4.1 MIPS R2000 / R3000 Registers 32-bit machine --> Programmable storage 2^32 x bytes 31 x 32-bit GPRs (R0 = 0) 32

More information

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,

More information

Control Instructions

Control Instructions Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set

More information

University of California, San Diego CSE 30 Computer Organization and Systems Programming Winter 2014 Midterm Dr. Diba Mirza

University of California, San Diego CSE 30 Computer Organization and Systems Programming Winter 2014 Midterm Dr. Diba Mirza Name Student ID University of California, San Diego CSE 30 Computer Organization and Systems Programming Winter 2014 Midterm Dr. Diba Mirza Name of person to your left Name of person to your right Please

More information

Chapter 2 Instructions Sets. Hsung-Pin Chang Department of Computer Science National ChungHsing University

Chapter 2 Instructions Sets. Hsung-Pin Chang Department of Computer Science National ChungHsing University Chapter 2 Instructions Sets Hsung-Pin Chang Department of Computer Science National ChungHsing University Outline Instruction Preliminaries ARM Processor SHARC Processor 2.1 Instructions Instructions sets

More information

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference. 1) [ 9 marks] Write a sequence of directives for an HCS12 assembly language program that performs all of these tasks, in this order: a) Define an array called Measurements starting from memory location

More information

CprE 288 Translating C Control Statements and Function Calls, Loops, Interrupt Processing. Instructors: Dr. Phillip Jones Dr.

CprE 288 Translating C Control Statements and Function Calls, Loops, Interrupt Processing. Instructors: Dr. Phillip Jones Dr. CprE 288 Translating C Control Statements and Function Calls, Loops, Interrupt Processing Instructors: Dr. Phillip Jones Dr. Zhao Zhang 1 Announcements Final Projects Projects: Mandatory Demos Deadweek

More information

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be "tricky") when you translate high-level code into assembler code.

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be tricky) when you translate high-level code into assembler code. MIPS Programming This is your crash course in assembler programming; you will teach yourself how to program in assembler for the MIPS processor. You will learn how to use the instruction set summary to

More information

Computer Organization & Assembly Language Programming (CSE 2312)

Computer Organization & Assembly Language Programming (CSE 2312) Computer Organization & Assembly Language Programming (CSE 2312) Lecture 15: Running ARM Programs in QEMU and Debugging with gdb Taylor Johnson Announcements and Outline Homework 5 due Thursday Midterm

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA CISC 662 Graduate Computer Architecture Lecture 4 - ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero 25 Comparisons Set on less than (slt) compares its source registers

More information

CMPSCI 201 Fall 2004 Midterm #1 Answers

CMPSCI 201 Fall 2004 Midterm #1 Answers CMPSCI 201 Fall 2004 Midterm #1 Answers 10 Points Short Essay Answer The 8088 is primarily a CISC processor design, and the ARM is primarily RISC. The 6502 is such an early design that it is difficult

More information

ARM Cortex-M4 Architecture and Instruction Set 4: The Stack and subroutines

ARM Cortex-M4 Architecture and Instruction Set 4: The Stack and subroutines ARM Cortex-M4 Architecture and Instruction Set 4: The Stack and subroutines M J Brockway February 13, 2016 The Cortex-M4 Stack SP The subroutine stack is full, descending It grows downwards from higher

More information

MIPS Functions and Instruction Formats

MIPS Functions and Instruction Formats MIPS Functions and Instruction Formats 1 The Contract: The MIPS Calling Convention You write functions, your compiler writes functions, other compilers write functions And all your functions call other

More information

Compiling Code, Procedures and Stacks

Compiling Code, Procedures and Stacks Compiling Code, Procedures and Stacks L03-1 RISC-V Recap Computational Instructions executed by ALU Register-Register: op dest, src1, src2 Register-Immediate: op dest, src1, const Control flow instructions

More information

Chapter 2. Instructions: Language of the Computer

Chapter 2. Instructions: Language of the Computer Chapter 2 Instructions: Language g of the Computer Stored Program Computers The BIG Picture Instructions represented in binary, just like data Instructions and data stored in memory Programs can operate

More information

Introduction to MIPS Processor

Introduction to MIPS Processor Introduction to MIPS Processor The processor we will be considering in this tutorial is the MIPS processor. The MIPS processor, designed in 1984 by researchers at Stanford University, is a RISC (Reduced

More information

CSCE 5610: Computer Architecture

CSCE 5610: Computer Architecture HW #1 1.3, 1.5, 1.9, 1.12 Due: Sept 12, 2018 Review: Execution time of a program Arithmetic Average, Weighted Arithmetic Average Geometric Mean Benchmarks, kernels and synthetic benchmarks Computing CPI

More information

The Assembly Language of the Boz 5

The Assembly Language of the Boz 5 The Assembly Language of the Boz 5 The Boz 5 uses bits 31 27 of the IR as a five bit opcode. Of the possible 32 opcodes, only 26 are implemented. Op-Code Mnemonic Description 00000 HLT Halt the Computer

More information

Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan

Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan ARM Programmers Model Hi Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan chanhl@maili.cgu.edu.twcgu Current program status register (CPSR) Prog Model 2 Data processing

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-08 In Class Example Handout Part A: J-Type Example: If you look in your book at the syntax for j (an unconditional jump instruction), you see something like: e.g. j addr would seemingly

More information

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD A. Assembly Language Programming Programming of a computer system: Machine code direct execution Assembly language tool: assembler High level programming language tool: interpreter tool: compiler Programming

More information

VE7104/INTRODUCTION TO EMBEDDED CONTROLLERS UNIT III ARM BASED MICROCONTROLLERS

VE7104/INTRODUCTION TO EMBEDDED CONTROLLERS UNIT III ARM BASED MICROCONTROLLERS VE7104/INTRODUCTION TO EMBEDDED CONTROLLERS UNIT III ARM BASED MICROCONTROLLERS Introduction to 32 bit Processors, ARM Architecture, ARM cortex M3, 32 bit ARM Instruction set, Thumb Instruction set, Exception

More information

Programming the ARM. Computer Design 2002, Lecture 4. Robert Mullins

Programming the ARM. Computer Design 2002, Lecture 4. Robert Mullins Programming the ARM Computer Design 2002, Lecture 4 Robert Mullins 2 Quick Recap The Control Flow Model Ordered list of instructions, fetch/execute, PC Instruction Set Architectures Types of internal storage

More information

administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions?

administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions? administrivia today start assembly probably won t finish all these slides Assignment 4 due tomorrow any questions? exam on Wednesday today s material not on the exam 1 Assembly Assembly is programming

More information

Chapter 2A Instructions: Language of the Computer

Chapter 2A Instructions: Language of the Computer Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction

More information

Computer Architecture

Computer Architecture Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers

More information

C-Style Strings. CS2253 Owen Kaser, UNBSJ

C-Style Strings. CS2253 Owen Kaser, UNBSJ C-Style Strings CS2253 Owen Kaser, UNBSJ Strings In C and some other low-level languages, strings are just consecutive memory locations that contain characters. A special null character (ASCII code 0)

More information

RCX internals (Revised February 24)

RCX internals (Revised February 24) CMSC 23000 Winter 2006 Operating Systems Handout 3 January 27 RCX internals (Revised February 24) 1 Introduction This document collects together various pieces of information about the hardware in the

More information

Instructions: Language of the Computer

Instructions: Language of the Computer CS359: Computer Architecture Instructions: Language of the Computer Yanyan Shen Department of Computer Science and Engineering 1 The Language a Computer Understands Word a computer understands: instruction

More information

ARM PROGRAMMING. When use assembly

ARM PROGRAMMING. When use assembly ARM PROGRAMMING Bùi Quốc Bảo When use assembly Functions that cannot be implemented in C, such as special register accesses and exclusive accesses Timing-critical routines Tight memory requirements, causing

More information

Unsigned and signed integer numbers

Unsigned and signed integer numbers Unsigned and signed integer numbers Binary Unsigned Signed 0000 0 0 0001 1 1 0010 2 2 0011 3 3 0100 4 4 Subtraction sets C flag opposite of carry (ARM specialty)! - if (carry = 0) then C=1 - if (carry

More information