(a) Look at this small block of ARM assembly language code: MOV R1,#0x4B MOV R2,
ID: 3673355 • Letter: #
Question
(a) Look at this small block of ARM assembly language code:
MOV R1,#0x4B
MOV R2,#-3
ADD R2,R1,R2
SUB R2,R1,R2
After the code has executed in sequence, what decimal values are left in the two registers? Give answers in decimal. [R1] =? [R2] =?
(b) The decimal numbers 3,4,5,6,7 have been stored in consecutive words in memory starting at address 0x320 .This ARM code is executed in sequence:
MOV R1,#0x320
LDR R7,[R1]
ADD R1,R1,#4
LDR R9,[R1]
ADD R10,R7,R9
STR R10,1004
What decimal values are in these registers and mem ory loc ation s after the code completes execution? Give answers in decimal. [R1] =? [R7 ] =? [R9] =? [R10] =? [0x320] =? [0x32C ] =?
(c) Registers R2 and R4 contain the decimal numbers 1500 and 4000 before each of the following addressing modes is used to access a memory operand. What is the effective address (EA) in each case?
(a) 12(R2 ), EA=
(b) (R2,R4 ), EA=
(c) 28(R2 ,R4 ), EA=
(d) (R4)+, EA =
(e) -(R4), EA =
Explanation / Answer
(a)
MOV R1,#0x4B ; R1 contains 0x4B = 75
MOV R2,#-3 ; R2 contains -3
ADD R2,R1,R2 ; Add R1, R2 and store the result in R2, R2 = 75+(-3) = 72
SUB R2,R1,R2 ; Subtract R2 from R1 and store result in R2, R2 = 75-72 = 3
So, [R1] = 75, [R2] = 3
(b)
----------------
Memory locations
----------------
0x320 : 3
0x324 : 4
0x328 : 5
0x32C : 6
0x330 : 7
----------------
MOV R1,#0x320 ; R1 contains 0x320
LDR R7,[R1] ; Load contents of R1 location to R7, R7 = [0x320] = 3
ADD R1,R1,#4 ; Add 4 to R1 and store result in R1, R1 = 0x324
LDR R9,[R1] ; Load contents of R1 location to R9, R9 = [0x324] = 4
ADD R10,R7,R9 ; Add R7, R9 and store result in R10, R10 = 3+4 = 7
STR R10,1004 ; Store the contents of R10 to memory location 1004 = 0x3EC
So, [R1]=0x324, [R7]=3 [R9]=4 [R10]=7 [0x320]=3 [0x32C]=6
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.