Tracing a conditional accumulation loop

An RV32I sensor-processing routine reads selected words from the memory shown below. All addresses and signed contents are decimal.


Memory words at byte addresses 2048, 2052, 2056, 2060, 2064, 2068 and 2072 contain 6, 19, 5, -4, -3, 8 and 5 respectively.


Initially, x10 = 2048, x11 = 4, x12 = 0, and x13 = 5. Register x0 always contains zero. The routine executes:


asm
loop:
    lw   x14, 0(x10)
    addi x10, x10, 8
    beq  x14, x13, skip
    add  x12, x12, x14
skip:
    addi x11, x11, -1
    bne  x11, x0, loop


Execution stops immediately after the final bne is not taken. All memory accesses are valid and aligned, and no arithmetic overflow occurs. What signed value does x12 contain at that point? Answer as a decimal integer with no decimal places.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Machine and Assembly Language Programming Questions: