Basic Assembly

The questions below are due on Sunday October 25, 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

Basic RISC-V Assembly

Arithmetic operations

For the following questions, assume register x1 is initialized to 0x00000005 and register x2 is initialized to 0x00000003. Note that these are hexadecimal values so they represent 32-bit wide values since the registers are all 32-bits wide. Assume that the registers are reinitialized before each question. You may find the RISC-V ISA handout useful.

What value is written into register x3 after executing the instruction xor x3, x1, x2?

What value is written into register x3 after executing the instruction srli x3, x1, 2?

What value is written into register x4 after executing the instruction addi x4, x0, 7?

What value is written into register x4 after executing the instruction lui x4, 7?

Control flow instructions

Consider the following sequence of instructions:

     addi x1, x0, 7
     addi x2, x0, 2
     bge x1, x2, L1
     addi x2, x2, 4
L1:  addi x2, x2, 5     

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

Now consider this slightly modified sequence of instructions:

     addi x1, x0, 7
     addi x2, x0, 2
     blt x1, x2, L1
     addi x2, x2, 4
L1:  addi x2, x2, 5     

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

Back to Exercises