Professional Documents
Culture Documents
Here, func may be any arithmetic operation (e.g.. add, sub, mult etc.)
where R1 is the destination reg. and R2,R3 are the source operands of the
instruction (meaning R1 <- R2+R3 ).
Example of I-format instructions:
add R1,R2,#8 Rs1 is R2, Rd is R1; the immediate constant
(8 in this case ) is stored in the
offset filed (LS 16bit of I-format)
beqz R1,loop (conditional branch instruction)
(Rs1 is R1 and Rs2 and Rd fields are unused.)
offset (to the instruction labelled loop)
from the current PC (actually PC+4) is
stored in the offset filed (LS 16bit of
I-format)
ld R2,8[R3] (Rs1 is R3 and Rd is R2; Rs2 is unused;
displacement (8 in this case) is stored
in the offset filed (LS 16bit of I-format
instruction)
st -16[R2],R1 (Rs1 is R2 and Rs2 is R1 ; Rd is unused)
displacement (-16 in this case) is in the
offset filed.
To get the immediate constant or displacement or offset from the
I-format instruction, the Imm (internal) register gets the
32-bit sign extended value of the offset field value.
Imm <-- SignExt(LS 16-bit of IR)