Calling Convention

The questions below are due on Sunday November 01, 2026; 11:59:00 PM.
 
You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Back to Exercises

RISC-V Assembly 2

Load and store operations

For the following questions assume that the registers have been initialized as follows:

x1 = 0x00000001 x2 = 0x00000002 x3 = 0x00000003 x4 = 0x00000004 x5 = 0x00000005

Also assume that you are told the contents of a few locations in main memory beginning at address 0x2000. The following notation implies that the value stored at address 0x2000 is 0x0F00FF00, the value stored at address 0x2004 is 0xA0A0A0A0, and the value stored at address 0x2008 is 0x11111111.

    . = 0x2000
    .word 0x0F00FF00
    .word 0xA0A0A0A0
    .word 0x11111111

Consider the following sequence of instructions:

     lui x1, 2
     lw x2, 4(x1)
     sw x3, 8(x1)

What value is written into register x2 after executing the instruction lw x2, 4(x1)?

Which memory location (which address) is written to by the sw x3, 8(x1) instruction?

What value is written to that memory location (provide your answer as a 32-bit hexadecimal)? 0x

Which registers are modified by this sequence of instructions? Include all modified registers in your answer.

Sign-Extension

Consider the following sequence of instructions:

     addi x2, zero, 0xF2
     addi x3, zero, 0xFF4

What value is left in register x2 after execution of this code segment?

What value is left in register x3 after execution of this code segment?

RISC-V Calling Convention

What set of registers are used to pass arguments to a procedure?

Which register is used to remember the return address from a procedure call?

The s0-s11 registers are callee-saved registers. This means that: (select all correct answers)

Which of the following statements are True in code that follows the RISC-V calling convention?

Back to Exercises