164k views
3 votes
Array A contains the 32-bit values {1, 2, 3, 4} and array B contains the 32-bit values {5, 6, 7, 8}. Determine the values in array A after executing the following sequence of ARM instructions.

LDR RO, =A
LDR R1, -B
MOV R2, #0
LDR R3, [RO, R2]
LDR R4. [R1, R2]
ADD R3, R4
STR R3, [R0, R2]
ADD R2, #8
LDR R3. [R0, R2]
LDR R4, [R1, R2]
SUB R4, R3
STR R4, [R0, R2]
A = {________, ________, ________, ________}

1 Answer

5 votes

Final answer:

The given sequence of ARM instructions perform various operations on arrays A and B, resulting in array A containing {6, 4, 3, 4}.

Step-by-step explanation:

The given sequence of ARM instructions perform various operations on the arrays A and B. Let's break down the instructions one by one:

  1. LDR RO, =A: This loads the address of array A into register RO.
  2. LDR R1, -B: This loads the address of array B into register R1, with a negative offset of -B.
  3. MOV R2, #0: This moves the value 0 into register R2.
  4. LDR R3, [RO, R2]: This loads the first element of array A into register R3.
  5. LDR R4, [R1, R2]: This loads the first element of array B into register R4.
  6. ADD R3, R4: This adds the values in R3 and R4 together.
  7. STR R3, [RO, R2]: This stores the sum back into the first element of array A.
  8. ADD R2, #8: This increments R2 by 8 to move to the next element.
  9. LDR R3, [RO, R2]: This loads the next element of array A into R3.
  10. LDR R4, [R1, R2]: This loads the next element of array B into R4.
  11. SUB R4, R3: This subtracts R3 from R4.
  12. STR R4, [RO, R2]: This stores the difference back into the next element of array A.

After executing all the instructions, the values in array A would be {6, 4, 3, 4}.

User Steven McGrath
by
8.0k points