Show the single RISC-V instruction or minimal sequence of instructions for this C statement: b = 25 | a. Assume that a corresponds to register x0 and b corresponds to register x1. Write each instruction in a separate box.
a = b - P[Q[4]];. For the C statement above, below is the MIPS code lw $x0, 16($x7) //a = Q[4] |
sll $x0, $x0, 2 //a = a*4 = Q[4]*4 |
add $x0, $x0, $x6 //a = &P[a] = &P[Q[4]] |
lw $x0, 0($x0) //a = P[a] = P[Q[4]] |
sub $x0, $x1, $x0 //a = b-a = b-P[Q[4]] |
variables a, b, c, d, and e are assigned to registers $x0, $x1, $x2, $x3, and $x4, respectively. Assume that the base address of the arrays P and Q are in registers $x6 and $x7, respectively. a = b - P[Q[4]]; |
Get Answers For Free
Most questions answered within 1 hours.