Question
Please do each part the question states.
Thanks!
Below is a RISC-style program with a byte-addressable memory. START-0x80 is the starting memory address of ten consecutive 32-bit data words: 88, 53, -3, -216, 62, -9, -105, 16, -2000, and -96 (all in decimal). What are the contents (in hexadecimal) of R1, R2, R3, and R4 after the execution of this program? Note that the comparisons consider signed numbers. For example, 0x06 is greater than OxFE if they are interpreted as signed numbers. Please assume 2's complement for negative numbers. Show how you get your results for partial credit. (20 pts, 5 each) Move Move Load Add R4, #START R5, #9 R1, (R4) R4, R4, #4 R2, (R4) LOOP: Load Branch_if_IR2RI NEXT Move Move R1, R2 R3, R4 R4, R4, #4 R5, R5, #1 NEXT: Add Subtract Branch_if_IR LOOP The numbers (in hexadecimal) in R1, R2, R3, and R4 are: [R1]= R2 R3] [R4] =
Explanation / Answer
Dry run:
R1: -2000
R2: -96
R3: 100
R4: 108
R1 R2 R3 R4 R5 Move R4, #START - - - 80 - Move R5, #9 - - - 80 9 Load R1, (R4) 88 - - 80 9 Add R4, R4, #4 88 - - 84 9 LOOP Load R2 (R4) 88 53 - 84 9 Branch if R2>R1, NEXT 84 Move R1 R2 53 53 - 84 9 Move R3 R4 53 53 84 84 9 NEXT Add R4, R4, #4 53 53 84 88 9 Subtract R5, R5, #1 53 53 84 88 8 Branch if R5 > 0, LOOP 84 88 LOOP Load R2 (R4) 53 -3 84 88 8 Branch if R2>R1, NEXT 84 88 Move R1 R2 -3 -3 84 88 8 Move R3 R4 -3 -3 88 88 8 NEXT Add R4, R4, #4 -3 -3 88 8C 8 Subtract R5, R5, #1 -3 -3 88 8C 7 Branch if R5 > 0, LOOP LOOP Load R2 (R4) -3 -216 88 8C 7 Branch if R2>R1, NEXT Move R1 R2 -216 -216 88 8C 7 Move R3 R4 -216 -216 8C 8C 7 NEXT Add R4, R4, #4 -216 -3 88 90 7 Subtract R5, R5, #1 -216 -3 88 90 6 Branch if R5 > 0, LOOP LOOP Load R2 (R4) -216 62 88 8C 6 Branch if R2>R1, NEXT Move R1 R2 Move R3 R4 NEXT Add R4, R4, #4 -216 62 88 94 6 Subtract R5, R5, #1 -216 62 88 94 5 Branch if R5 > 0, LOOP LOOP Load R2 (R4) -216 -9 88 94 5 Branch if R2>R1, NEXT Move R1 R2 Move R3 R4 NEXT Add R4, R4, #4 -216 -9 88 98 5 Subtract R5, R5, #1 -216 -9 88 98 4 Branch if R5 > 0, LOOP LOOP Load R2 (R4) -216 -105 88 98 4 Branch if R2>R1, NEXT Move R1 R2 Move R3 R4 NEXT Add R4, R4, #4 -216 -105 88 9C 4 Subtract R5, R5, #1 -216 -105 88 9C 3 Branch if R5 > 0, LOOP LOOP Load R2 (R4) -216 16 88 9C 3 Branch if R2>R1, NEXT Move R1 R2 Move R3 R4 NEXT Add R4, R4, #4 -216 16 88 100 3 Subtract R5, R5, #1 -216 16 88 100 2 Branch if R5 > 0, LOOP LOOP Load R2 (R4) -216 -2000 88 100 2 Branch if R2>R1, NEXT Move R1 R2 -2000 2000 88 100 2 Move R3 R4 -2000 2000 100 100 2 NEXT Add R4, R4, #4 -2000 2000 100 104 2 Subtract R5, R5, #1 -2000 2000 100 104 1 Branch if R5 > 0, LOOP LOOP Load R2 (R4) -2000 -96 100 104 1 Branch if R2>R1, NEXT Move R1 R2 Move R3 R4 NEXT Add R4, R4, #4 -2000 -96 100 108 1 Subtract R5, R5, #1 -2000 -96 100 108 0 Branch if R5 > 0, LOOP