Name: Date:
HW6
-
You are writing a RISC-V assembly program. Your program has a
beqinstruction at address0x0100 0400. You wish thisbeqto branch to location0x0200 0000.- (3 points) How close a single
beqinstruction get to the goal address? Express your answer as the address nearest to the target address as possible.
- (3 points) What is a possible method to allow long-range conditional branches?
- (3 points) How close a single
-
You are writing a program for a processor with 8-bit instructions. The branch instructions for this processor only allow 3-bit branch immediate.
- (3 points) Assuming the immediate is sign extended, what is the branch range of the processor? Answer in byte units.
- (3 points) What is the difficulty with such a branch range? Write out a simple while loop example to illustrate the difficulty.
-
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 0x00400028jal x0, test
0x0040002cloop: lw t1, 0(t2)
0x00400030addi t3, t3, -4
0x00400034test: bne t1, x0, loop
- (3 points) List both the byte offset and immediate used by the
jalinstruction? Show your work.
- (3 points) What is the hex value for the immediate in the
bneinstruction? Show your work.
- (3 points) List both the byte offset and immediate used by the