1) What is the addressind mode and effective address of each instruction set? 1)
ID: 2291907 • Letter: 1
Question
1) What is the addressind mode and effective address of each instruction set?
1) LDRSB R1, [R0], #2
2) LDRSB R2, [R0, R4, LSL #1]!
3) STRH R3, [R0, #-6]
2) What will be the values (in Hex) stored in the registers after the code is executed?
3) What will be the content of the memory (in hex) after the code segment is executed?
memory 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 address 0x0000.2001 0x0000.2004 RO 0x0000.2002 OxAAAA.AAAA R1 0x0000.2003 0x8BBB.BBBB?R2 0x0000. 2004 Ox1234.5678 R3 0x0000.2005 0x0000.0001 R4 0x0000.2006 register 0x0000.2007 0x0000.2008 LDRSB LDRSB STRH RI , R2, R3, [Roj, #2 [R0 , R4, LSL [R0 , #-6] #1] !Explanation / Answer
Answer :- 1)1) LDRSB R1, [R0], #2 has post-indexed offset addressing mode. Effective address = R0
2) LDRSB R2, [R0, R4, LSL #1]! has pre-indexed offset addressing mode. Effective address = R0 + R4*2
3) STRH R3, [R0, #-6] has pre-indexed offset addressing mode. Effective address = R0 - 6
Answer :- 2 and 3) Register R1 gets value of 0x44 due to the first instruction. That is value from address 0x0000_2004 is loaded into register R0. Register R0 is then changed to 0x0000_2006.
In second instruction, R0 = R0 + R4*2 = 0x0000_2006 + (0x0000_0001)*2 = 0x0000_2008. Then value from address 0x0000_2008 is copied into register R2, so register R2 = 0x88.
In the third instruction, first R0 = R0 - 6 = 0x0000_2002. Then value in R3 is copied to address stored in R0. So value in R3 i.e. 0x1234_5678 is copied to memory address 0x0000_2002.
So at memory address 0x0000_2002 value 0x78 is kept.
At memory address 0x0000_2003, value 0x56 is kept.
At memory address 0x0000_2004, value 0x34 is kept.
At memory address 0x0000_2005, value 0x12 is kept.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.