Pseudo And Assembly Form Workbench

RISC-V Pseudo-Instruction And Assembly Form Reference

This workbench follows the official RISC-V assembly manual for pseudo-instructions, assembler aliases, and standard encoding spellings, so you can read li, call, ret, fence.tso, and related forms before checking the real instruction or encoding for behavior, range, and caveats.

59 entries59 visible
Know The Layer

Pseudo-instructions and assembly forms belong to the assembler layer; performance, traps, extension requirements, and immediate ranges come from the expanded real instruction or encoding.

Read The Expansion

The same spelling may vary by XLEN, PIC/nopic mode, symbol distance, available extensions, or linker relaxation; detail pages call out the common paths.

Official Sources

Expansion tables follow the RISC-V Assembly Programmer's Manual; real-instruction semantics follow the Unprivileged ISA; ABI and relocation wording follows the psABI.

By Use

Pseudo Results

59 visible

call

Assembler pseudo-instruction

Chapter 26 of the RISC-V Assembly Programmer's Manual lists call symbol and call rd, symbol as assembler pseudoinstructions for calling a far-away subroutine. call symbol implicitly uses ra as the link register to save the return address, while call rd, symbol uses the specified rd instead. The psABI associates the AUIPC+JALR pair generated by CALL with R_RISCV_CALL or R_RISCV_CALL_PLT.

call
Details
You Write
call symbol call rd, symbol
Expands To
auipc ra, 0 jalr ra, ra, 0

j

Assembler pseudo-instruction

RISC-V j is written as j offset in the RISC-V Assembly Programmer's Manual and expands to jal x0, offset. The Unprivileged ISA identifies J as the JAL assembler pseudo-instruction with rd=x0.

j
Details
You Write
j offset
Expands To
jal x0, offset

la

Assembler pseudo-instruction

The RISC-V Assembly Programmer's Manual lists two la expansions: AUIPC plus ADDI with .option nopic, and AUIPC plus a GOT-based l{w|d} load with .option pic.

la
Details
You Write
la rd, symbol
Expands To
.option nopic auipc rd, symbol[31:12] addi rd, rd, symbol[11:0] .option pic auipc rd, symbol@GOT[31:12] l{w|d} rd, symbol@GOT[11:0](rd)

li

Assembler pseudo-instruction

RISC-V li is written as li rd, immediate in the RISC-V Assembly Programmer's Manual and means Load immediate. Its expansion is listed as Myriad sequences, with different sequences possible for a numeric value.

li
Details
You Write
li rd, immediate
Expands To
Myriad sequences

mv

Assembler pseudo-instruction

RISC-V mv is written as mv rd, rs in the RISC-V Assembly Programmer's Manual and expands to addi rd, rs, 0. The Unprivileged ISA states that ADDI rd, rs1, 0 implements MV.

mv
Details
You Write
mv rd, rs
Expands To
addi rd, rs, 0

nop

Assembler pseudo-instruction

The RISC-V nop pseudo-instruction has the nop expansion ADDI x0, x0, 0, the canonical NOP encoding. It does not change architecturally visible state apart from PC advance and applicable counters.

Details
You Write
nop
Expands To
addi x0, x0, 0

ret

Assembler pseudo-instruction

The RISC-V ret pseudo-instruction has the ret expansion JALR x0, x1, 0 and means return from subroutine. JALR forms its target from rs1 plus a sign-extended 12-bit immediate and clears the low bit.

Details
You Write
ret
Expands To
jalr x0, x1, 0

beqz

Assembler pseudo-instruction

The RISC-V beqz pseudo-instruction has the beqz expansion BEQ rs, x0, offset and branches if the register equals zero. Its conditional branch range is plus or minus 4 KiB.

Details
You Write
beqz rs, offset
Expands To
beq rs, x0, offset

bnez

Assembler pseudo-instruction

The RISC-V bnez pseudo-instruction has the bnez expansion BNE rs, x0, offset and branches if the register is not equal to zero. Its conditional branch range is plus or minus 4 KiB.

Details
You Write
bnez rs, offset
Expands To
bne rs, x0, offset

jr

Assembler pseudo-instruction

jr expands to jalr x0, rs, 0. JALR forms its target from rs plus a sign-extended 12-bit immediate and clears target bit zero.

Details
You Write
jr rs
Expands To
jalr x0, rs, 0

tail

Assembler pseudoinstruction

tail symbol is a pseudoinstruction for a far-away subroutine tail call. Its default base instructions are auipc x6, offset[31:12] and jalr x0, x6, offset[11:0]; with Zicfilp, x7 is used as a scratch register.

tail
Details
You Write
tail symbol
Expands To
auipc x6, offset[31:12] jalr x0, x6, offset[11:0]

neg

Assembler pseudo-instruction

neg expands to sub rd, x0, rs. SUB computes zero minus rs, ignores overflow, and writes the low XLEN result bits to rd.

Details
You Write
neg rd, rs
Expands To
sub rd, x0, rs

not

Assembler pseudo-instruction

RISC-V not pseudo-instruction expands to xori rd, rs, -1. XORI applies bitwise XOR with a sign-extended 12-bit immediate; -1 performs bitwise logical inversion and writes rd.

notpseudoinstructionbitwise NOTXORIbit manipulationones' complement
Details
You Write
not rd, rs
Expands To
xori rd, rs, -1

seqz

Assembler pseudo-instruction

RISC-V seqz pseudo-instruction expands to sltiu rd, rs, 1. SLTIU is an unsigned comparison; this form writes 1 to rd only when rs is zero, otherwise 0.

seqzpseudoinstructionset if zeroSLTIUnull pointer checkbooleanize
Details
You Write
seqz rd, rs
Expands To
sltiu rd, rs, 1

snez

Assembler pseudo-instruction

RISC-V snez pseudo-instruction expands to sltu rd, x0, rs. SLTU is an unsigned comparison; this form writes 1 to rd only when rs is not zero, otherwise 0.

snezpseudoinstructionset if nonzeroSLTUbooleanizenon-zero detection
Details
You Write
snez rd, rs
Expands To
sltu rd, x0, rs

lga

Assembler pseudoinstruction

RISC-V lga rd, symbol is an assembler pseudoinstruction for a global-symbol address. Its documented sequence is AUIPC plus a GOT load: ld on RV64 and lw on RV32.

RISC-V lgalga rdglobal-symbol addressGOT loadld on RV64
Details
You Write
lga rd, symbol
Expands To
auipc rd, symbol@GOT[31:12] l{w|d} rd, symbol@GOT[11:0](rd)

lla

Assembler pseudoinstruction

RISC-V lla rd, symbol is an assembler pseudoinstruction for a local-symbol address. It uses AUIPC and a PC-relative low immediate, expanding to AUIPC plus ADDI.

RISC-V llalla rdlocal-symbol addressPC-relative low immediate
Details
You Write
lla rd, symbol
Expands To
auipc rd, symbol[31:12] addi rd, rd, symbol[11:0]

sgtz

Assembler pseudo-instruction

RISC-V sgtz pseudo-instruction expands to slt rd, x0, rs. SLT is a signed comparison; this form writes 1 to rd when rs is greater than zero, otherwise 0.

sgtzpseudoinstructioncomparesignedpositivepseudo-instruction
Details
You Write
sgtz rd, rs
Expands To
slt rd, x0, rs

sltz

Assembler pseudo-instruction

RISC-V sltz pseudo-instruction expands to slt rd, rs, x0. SLT is a signed comparison; this form writes 1 to rd when rs is less than zero, otherwise 0.

sltzpseudoinstructioncomparesignednegativepseudo-instruction
Details
You Write
sltz rd, rs
Expands To
slt rd, rs, x0

csrr

Assembler pseudo-instruction

The RISC-V csrr pseudo-instruction has the csrr expansion CSRRS rd, csr, x0 for read CSR. With rs1 as x0 it does not write the CSR, though read side effects may occur.

Details
You Write
csrr rd, csr
Expands To
csrrs rd, csr, x0

csrw

csrw expands to csrrw x0, csr, rs. rd=x0 does not read the CSR.

Details
You Write
csrw csr, rs
Expands To
csrrw x0, csr, rs

csrc

Assembler pseudo-instruction

csrc expands to csrrc x0, csr, rs. CSRRC clears writable CSR bits selected by rs and writes the old value to x0.

Details
You Write
csrc csr, rs
Expands To
csrrc x0, csr, rs

csrs

Assembler pseudo-instruction

csrs expands to csrrs x0, csr, rs. CSRRS sets writable CSR bits selected by rs and writes the old value to x0.

Details
You Write
csrs csr, rs
Expands To
csrrs x0, csr, rs

csrci

Assembler pseudoinstruction

RISC-V csrci expands to csrrci x0, csr, imm. Its zero-extended uimm clears writable CSR bits.

csrci
Details
You Write
csrci csr, imm
Expands To
csrrci x0, csr, imm

csrsi

Assembler pseudoinstruction

RISC-V csrsi expands to csrrsi x0, csr, imm. Its zero-extended uimm sets writable CSR bits.

csrsi
Details
You Write
csrsi csr, imm
Expands To
csrrsi x0, csr, imm

csrwi

Assembler pseudoinstruction

RISC-V csrwi expands to csrrwi x0, csr, imm. Its zero-extended uimm writes the CSR.

csrwi
Details
You Write
csrwi csr, imm
Expands To
csrrwi x0, csr, imm

bgez

bgez expands to bge rs, x0, offset. BGE is signed and uses a B-type offset.

Details
You Write
bgez rs, offset
Expands To
bge rs, x0, offset

bgt

bgt expands to blt rt, rs, offset. It reverses BLT operands.

Details
You Write
bgt rs, rt, offset
Expands To
blt rt, rs, offset

bgtu

Assembler pseudo-instruction

bgtu expands to bltu rt, rs, offset. It branches when rs is greater than rt under unsigned comparison.

Details
You Write
bgtu rs, rt, offset
Expands To
bltu rt, rs, offset

bgtz

Assembler pseudo-instruction

bgtz expands to blt x0, rs, offset. It branches when rs is greater than zero under signed comparison.

Details
You Write
bgtz rs, offset
Expands To
blt x0, rs, offset

ble

Assembler pseudo-instruction

ble expands to bge rt, rs, offset. It branches when rs is less than or equal to rt under signed comparison.

Details
You Write
ble rs, rt, offset
Expands To
bge rt, rs, offset

bleu

Assembler pseudo-instruction

bleu expands to bgeu rt, rs, offset. It branches when rs is less than or equal to rt under unsigned comparison.

Details
You Write
bleu rs, rt, offset
Expands To
bgeu rt, rs, offset

blez

Assembler pseudo-instruction

blez expands to bge x0, rs, offset. It branches when rs is less than or equal to zero under signed comparison.

Details
You Write
blez rs, offset
Expands To
bge x0, rs, offset

bltz

Assembler pseudo-instruction

bltz expands to blt rs, x0, offset. BLT branches when rs is less than x0 under signed comparison.

Details
You Write
bltz rs, offset
Expands To
blt rs, x0, offset

frflags

frflags expands to csrrs rd, fflags, x0. fflags is the accrued exception field at fcsr bits 4:0.

Details
You Write
frflags rd
Expands To
csrrs rd, fflags, x0

fsflags

fsflags uses CSRRW forms for fflags at fcsr bits 4:0.

Details
You Write
fsflags rd, rs fsflags rs
Expansion By Form
fsflags rd, rs
csrrw rd, fflags, rs
fsflags rs
csrrw x0, fflags, rs

frcsr

Assembler pseudo-instruction

RISC-V frcsr is an Assembly Manual v0.0.1 pseudo-instruction. It expands to csrrs rd, fcsr, x0; ISA Section 21.2 says it copies fcsr into integer register rd.

RISC-V frcsrfrcsr pseudo-instructionfrcsr CSRRS expansionread FP control statuscsrrs rd fcsr
Details
You Write
frcsr rd
Expands To
csrrs rd, fcsr, x0

frrm

Assembler pseudo-instruction

RISC-V frrm is an Assembly Manual v0.0.1 pseudo-instruction. It expands to csrrs rd, frm, x0; ISA Section 21.2 copies frm into rd's low three bits.

RISC-V frrmfrrm pseudo-instructionfrrm CSRRS expansionread FP rounding modecsrrs rd frm
Details
You Write
frrm rd
Expands To
csrrs rd, frm, x0

fscsr

Assembler pseudo-instruction

fscsr expands to CSRRW to write fcsr. The two-operand form reads and returns the old value only when rd is not x0; the one-operand form uses x0.

RISC-V fscsrfscsr pseudo-instructionfscsr CSRRW expansionswap FP control statuscsrrw rd fcsr
Details
You Write
fscsr rd, rs fscsr rs
Expansion By Form
fscsr rd, rs
csrrw rd, fcsr, rs
fscsr rs
csrrw x0, fcsr, rs

fsflagsi

Assembler pseudo-instruction

RISC-V fsflagsi uses CSRRWI to write fflags with a five-bit zero-extended immediate. It reads and returns the old value only when rd is not x0.

RISC-V fsflagsifsflagsi pseudo-instructionfsflagsi CSRRWI expansionFP flags immediatecsrrwi rd fflags
Details
You Write
fsflagsi rd, imm fsflagsi imm
Expansion By Form
fsflagsi rd, imm
csrrwi rd, fflags, imm
fsflagsi imm
csrrwi x0, fflags, imm

fsrm

Assembler pseudo-instruction

fsrm uses CSRRW to write the low three bits of rs to frm. It reads and returns the old value only when rd is not x0; rd=x0 and the one-operand form do not read frm.

RISC-V fsrmfsrm pseudo-instructionfsrm CSRRW expansionswap FP rounding modecsrrw rd frm
Details
You Write
fsrm rd, rs fsrm rs
Expansion By Form
fsrm rd, rs
csrrw rd, frm, rs
fsrm rs
csrrw x0, frm, rs

fsrmi

Assembler pseudoinstruction

RISC-V fsrmi is an assembler pseudoinstruction for frm: fsrmi rd, imm expands to csrrwi rd, frm, imm, while fsrmi imm uses x0; the CSR immediate field is five bits.

RISC-V fsrmifsrmi rdfsrmi immcsrrwi rdCSR immediate field
Details
You Write
fsrmi rd, imm fsrmi imm
Expansion By Form
fsrmi rd, imm
csrrwi rd, frm, imm
fsrmi imm
csrrwi x0, frm, imm

jal

Assembler alias (one-operand jal)

RISC-V jal offset is an assembler alias for jal x1, offset. JAL writes pc+4 to rd and uses a signed, two-byte-multiple offset with a plus-or-minus 1 MiB range.

RISC-V jaljal offsetjal x1JAL writes1 MiB range
Details
You Write
jal offset
Expands To
jal x1, offset

jalr

Assembler alias (one-register jalr)

RISC-V jalr rs is an assembler alias for jalr x1, rs, 0. JALR adds a sign-extended 12-bit immediate to rs1, clears target bit zero, and writes pc+4 to rd.

RISC-V jalrjalr rsjalr x112-bit immediatetarget bit zero
Details
You Write
jalr rs
Expands To
jalr x1, rs, 0

sext-w

Assembler pseudo-instruction

The RISC-V sext.w pseudo-instruction expands to addiw rd, rs, 0. This RV64I form writes the sign extension of rs's low 32 bits to rd.

sext.w pseudo-instructionaddiw rd rs 0RV64I formlow 32 bitssign extension
Details
You Write
sext.w rd, rs
Expands To
addiw rd, rs, 0

negw

Assembler pseudo-instruction

RISC-V negw is an RV64 assembler pseudo-instruction that expands to subw rd, x0, rs. SUBW subtracts in the low 32 bits, then sign-extends the 32-bit result to XLEN.

negwRV64I
Details
You Write
negw rd, rs
Expands To
subw rd, x0, rs

rdcycle

Assembler pseudo-instruction

RISC-V rdcycle is the pseudo-instruction for the cycle CSR and expands to csrrs rd, cycle, x0. It reads the low XLEN bits; when XLEN is at least 64, it reads the full 64-bit counter.

rdcycleZicntr
Details
You Write
rdcycle rd
Expands To
csrrs rd, cycle, x0

rdcycleh

Assembler pseudo-instruction

RISC-V rdcycleh is the pseudo-instruction for the cycle high half and expands to csrrs rd, cycleh, x0. It exists only when XLEN=32 and reads bits 63 through 32 of the same 64-bit cycle counter.

rdcyclehRV32
Details
You Write
rdcycleh rd
Expands To
csrrs rd, cycleh, x0

rdinstret

Assembler pseudo-instruction

RISC-V rdinstret is the pseudo-instruction for the instret CSR and expands to csrrs rd, instret, x0. It reads the low XLEN bits; instret counts instructions retired by this hart from an arbitrary past start point.

rdinstretZicntr
Details
You Write
rdinstret rd
Expands To
csrrs rd, instret, x0

rdinstreth

Assembler pseudo-instruction

The RISC-V rdinstreth pseudo-instruction expands to csrrs rd, instreth, x0 and, only on RV32, reads bits 63:32 of the instret counter.

rdinstreth pseudo-instructioncsrrs rd instrethinstret counterRV32 instrethigh 32 bits
Details
You Write
rdinstreth rd
Expands To
csrrs rd, instreth, x0

rdtime

Assembler pseudo-instruction

The RISC-V rdtime pseudo-instruction expands to csrrs rd, time, x0 and reads the time CSR low XLEN bits.

rdtime pseudo-instructioncsrrs rd timetime CSRlow XLEN bitsZicntr
Details
You Write
rdtime rd
Expands To
csrrs rd, time, x0

rdtimeh

Assembler pseudo-instruction

The RISC-V rdtimeh pseudo-instruction expands to csrrs rd, timeh, x0 and, only on RV32, reads bits 63:32 of the time counter.

rdtimeh pseudo-instructioncsrrs rd timehtime counterRV32 timehigh 32 bits
Details
You Write
rdtimeh rd
Expands To
csrrs rd, timeh, x0

zext-b

Assembler pseudo-instruction

The RISC-V zext.b pseudo-instruction expands to andi rd, rs, 255. ANDI bitwise-ANDs rs with a sign-extended 12-bit immediate; 255 retains the low 8 bits.

zext.b pseudo-instructionandi rd rs 255sign extended 12 bitlow 8 bitszero extension
Details
You Write
zext.b rd, rs
Expands To
andi rd, rs, 255

zext-h

Zbb/Zbkb instruction; equivalent shift sequence

The zext.h instruction zero-extends the low 16 bits to XLEN. It is provided by the Zbb extension and also by the Zbkb extension via RV32 PACK or RV64 PACKW with rs2=x0. The Assembly Manual lists an equivalent SLLI/SRLI shift sequence.

zext.h instructionZbb extensionZbkb extensionshift sequencelow 16 bitszero extension
Details
You Write
zext.h rd, rs
Equivalent Shift Sequence
slli rd, rs, XLEN - 16 srli rd, rd, XLEN - 16

zext-w

Assembler pseudo-instruction

The RISC-V zext.w pseudo-instruction expands to slli rd, rs, XLEN - 32 then srli rd, rd, XLEN - 32 to zero-extend a word. On RV64 with Zba available, the table has a single-instruction form.

zext.w pseudo-instructionslli srli sequenceRV64 with Zbalow 32 bitszero extension
Details
You Write
zext.w rd, rs
Expands To
slli rd, rs, XLEN - 32 srli rd, rd, XLEN - 32

pause

Zihintpause PAUSE HINT instruction (assembly spelling: pause)

The Assembly Manual lists pause as the PAUSE-hint assembly spelling for fence w, 0. The Unprivileged ISA defines PAUSE as a Zihintpause HINT instruction that indicates the current hart should temporarily reduce or pause its instruction-retirement rate; the effect duration is bounded and may be zero.

pauseZihintpause
Details
You Write
pause
Expands To
fence w, 0

sbreak

Legacy compatibility name

RISC-V sbreak is the previous name of EBREAK; the specification says they have the same functionality and encoding, and EBREAK is used to return control to a debugging environment.

sbreak legacy nameEBREAKsame functionality and encodinglegacy compatibility nameRISC-V sbreak
Details
You Write
sbreak
Expands To
EBREAK

scall

Legacy compatibility name

RISC-V scall is the previous name of ECALL; the specification says they have the same functionality and encoding, and ECALL is used to make a service request to the execution environment.

scall legacy nameECALLsame functionality and encodinglegacy compatibility nameRISC-V scall
Details
You Write
scall
Expands To
ECALL

fence-tso

Real FENCE instruction encoding spelling

RISC-V FENCE.TSO is a real FENCE spelling with fm=1000, pred=RW, succ=RW; non-AMO store-to-load remains unordered.

fence.tso
Details
You Write
fence.tso
Encoding Form
FENCE.TSO # fm=1000, pred=RW, succ=RW