Try   HackMD

Computer Architecture: Quiz

  1. Assume the base address of array A[] is stored in register s0. Describe what the following RISC-V instructions (RV32I) do:
lw t0, 0(s0)
lw t1, 8(s0)
add t2, t0, t1
sw t2, 4 (s0)
  1. Inside a procedure the following code is found:
testproced:
    addi sp, sp, -12
    sw ra, 0(sp)
    sw s0, 4(sp)
    sw s1, 8(sp)
    ...

Answer the questions below:
a) what might be a reason be for saving the return address on the stack?
b) why is the stack pointer decremented by 12?
c) show the last 4 lines of this procedure which immediately precede the return from procedure instruction (or jalr instruction):