Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

arks): Suppose that we need to write a RISC-style p 6] and ARR2- 13, 6, 4, 2] in

ID: 3588136 • Letter: A

Question


arks): Suppose that we need to write a RISC-style p 6] and ARR2- 13, 6, 4, 2] in and stor ARRI with last e rogram that adds the two arrays ARRI- [2 a reverse order and store the result in ARR3 (that is add the first element of lement of ARR2 and put the result in the first element of ARR3, the second element of with second last element of ARR2 and put the result in the second eler ment of ARR3, an so What instructions you will use at lines: 2, 6, 9, 12, 14, and 15. Solution: Movia RI,#N 2. Movia Movia Movie R2, #ARRI R3, #ARR2 R4, #ARR3 4. 5. 6. 7. Loop: Load R5. (R2) R6, (R3) 9 Store Add 10. R5, (R4) R2, R2, #4 12. Add R4, R4, #4 14 15. ORIGIN Ox500 16. 17. N DATAWORD 4 18. ARRI: DATAWORD 2,3, 5, 6 19. ARR2: DATAWORD 3. 6,4, 2 20. ARR3: RESERVE16

Explanation / Answer

For the given instructions to add Two Arrays in reverse in 3rd array, following are the missing instructions:

2. Sub SP, SP, #4 ; to create the stack

6. Add R3, R3 , #12 ;Move the pointer to last element of 2nd array

9. Add R5, R5, R6 ; addition of two arrays

12. Sub R3, R3, #4 ;decrement of pointer of 2nd array

14. Sub.s R1, R1, #1 ; decrement of counter

15. Bne Loop ; to End the loop