Skip to content

Latest commit

 

History

History
71 lines (45 loc) · 1020 Bytes

pseudo_equivalents_pdf.adoc

File metadata and controls

71 lines (45 loc) · 1020 Bytes
Table 1. Pseudoinstruction Equivalents
Pseudoinstruction Example Use Equivalence

Load Immediate

li     t0, 42
ori    t0, x0, 42
# or
addi   t0, x0, 42

Move

mv     t0, t1
or     t0, x0, t1
# or
add    t0, x0, t1
# or
addi   t0, t1, 0

Load Address

la     t0, label
lui    t0, 0x10010
ori    t0, t0, byte_offset

Branch Less Than or Equal

ble   t0, t1, label
# test for < and = separately
blt     t0,  t1, label
beq     t0,  t1, label
# or add 1 to change <= to <
# use a spare reg if you need
# to preserve the original value
addi    t3, t1, 1
blt     t0, t3, label

Branch Greater Than

bgt   t0, t1, label
# flip the operands and use blt
blt   t1, t0, label

Return

ret
# as mentioned in chapter 5
jalr   x0, ra, 0

Jump Register

jr   t0
# as mentioned in chapter 5
jalr   x0, t0, 0