do isboththefirstparameterandreturn
value
Topic V0A
IsBra Programming Example
1
, Sample
Question Always go to the target
One way to implement a “branch always” (bra) instruction, is to use the
beq instruction and to make both registers the same. For example:
beq t0, t0, LABEL
LABEL
if 2 2 Always true
Binary format of a branch instruction:
31 25 24 20 19 15 14 12 11 7 6 0
imm[12|10:5] rs2 rs1 func3 imm[4:1|11] op
Write the RISC-V code for a function IsBra that receives the binary code
of a beq instruction in a0 and returns 1 in a0 if it is a bra and returns 0
in a0 otherwise.
2
value
Topic V0A
IsBra Programming Example
1
, Sample
Question Always go to the target
One way to implement a “branch always” (bra) instruction, is to use the
beq instruction and to make both registers the same. For example:
beq t0, t0, LABEL
LABEL
if 2 2 Always true
Binary format of a branch instruction:
31 25 24 20 19 15 14 12 11 7 6 0
imm[12|10:5] rs2 rs1 func3 imm[4:1|11] op
Write the RISC-V code for a function IsBra that receives the binary code
of a beq instruction in a0 and returns 1 in a0 if it is a bra and returns 0
in a0 otherwise.
2