Name: Date:


  1. You are writing a RISC-V assembly program. Your program has a beq instruction at address 0x0100 0400. You wish this beq to branch to location 0x0200 0000.

    1. (3 points) How close can the beq get to the goal address? Express your answer as the address nearest to the target address as possible.
    1. (3 points) What is a possible method to allow long-range conditional branches?
  2. You are writing a program for a processor with 8-bit instructions. The branch instructions for this processor only allow 3-bit branch immediate.

    1. (3 points) Assuming the immediate is sign extended, what is the branch range of the processor?
    1. (3 points) What is the problem with such a branch range?
  1. Compute the correct hex value for the branch targets below, give your answers in the correct number of digits in hexidecimal, including any leading zeros.

    Address Instruction
          jal x0, test            
    loop: lw   t1, 0(t2)  
          addi t3, t3, -4 
    test: bne  t1, x0, loop
    1. (3 points) List both the byte offset and immediate used by the jal instruction? Show your work.
    1. (3 points) What is the hex value for the immediate in the bne instruction? Show your work.