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

Far function call pseudo-instruction using an AUIPC+JALR PC-relative call sequence. Unlike JAL's ±1 MiB limit, call is common for cross-module, shared-library, or dynamically linked calls and can be relaxed by the linker.

callpseudoinstructionfunction callAUIPCJALRfar call
Details
You Write
call symbol / call rd, symbol
Expands To
auipc ra, offset[31:12] jalr ra, offset[11:0](ra) # or call rd, symbol: auipc rd, offset[31:12] jalr rd, offset[11:0](rd)

j

Assembler pseudo-instruction

Unconditional jump pseudo-instruction expands to jal x0, offset. Transfers control within ±1 MiB without saving a return address. Commonly used for goto, infinite loops, and switch-case jump tables.

jpseudoinstructionunconditional jumpJALcontrol flowgoto
Details
You Write
j offset
Expands To
jal x0, offset

li

Assembler pseudo-instruction

Load-integer-immediate pseudo-instruction. The assembler chooses one or more real instructions according to the constant, XLEN, and available extensions; small signed 12-bit values can use ADDI, while larger constants commonly need LUI/ADDI or more steps.

lipseudoinstructionload immediateADDILUIconstant
Details
You Write
li rd, immediate
Expands To
addi rd, x0, imm # or: assembler-selected multi-instruction sequence such as LUI/ADDI/ADDIW/SLLI as needed

mv

Assembler pseudo-instruction

Register-to-register copy pseudo-instruction, expands to addi rd, rs, 0. Expresses assignment semantics more clearly than raw ADDI. Heavily used by compilers for register allocation, function argument setup, and temporary value preservation.

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

nop

Assembler pseudo-instruction

No-operation pseudo-instruction, expands to addi x0, x0, 0. Changes no architectural state except advancing PC. Primarily used for code alignment, icache line padding, and runtime code patch reservation.

noppseudoinstructionno-opADDIcode alignmentinstruction padding
Details
You Write
nop
Expands To
addi x0, x0, 0

ret

Assembler pseudo-instruction

Return from subroutine pseudo-instruction, expands to jalr x0, 0(ra). Jumps back to the caller indirectly via the ra register. The standard return mechanism in RISC-V function epilogues.

retpseudoinstructionfunction returnJALRrareturn
Details
You Write
ret
Expands To
jalr x0, 0(ra)

la

Assembler pseudo-instruction

Load-address pseudo-instruction that places a symbol address in a register. The official assembly manual defines different expansions for .option nopic versus pic: typically AUIPC+ADDI for non-PIC and GOT-indirect loading for PIC.

lapseudoinstructionload addresssymbol addressAUIPCADDI
Details
You Write
la rd, symbol
Expands To
# .option nopic .Lla: auipc rd, %pcrel_hi(symbol) addi rd, rd, %pcrel_lo(.Lla) # .option pic .Lla_got: auipc rd, %got_pcrel_hi(symbol) l{w|d} rd, %pcrel_lo(.Lla_got)(rd)

beqz

Assembler pseudo-instruction

Branch if equal zero pseudo-instruction, expands to beq rs, x0, offset. Branches when a register equals zero. Common for null pointer checks, loop termination, and flag testing.

beqzpseudoinstructionbranch if zeroBEQnull pointerloop exit
Details
You Write
beqz rs, offset
Expands To
beq rs, x0, offset

bnez

Assembler pseudo-instruction

Branch if not equal zero pseudo-instruction, expands to bne rs, x0, offset. Branches when a register is non-zero. Common for non-null guard checks, loop continuation, and boolean testing.

bnezpseudoinstructionbranch if nonzeroBNEguard checkloop continue
Details
You Write
bnez rs, offset
Expands To
bne rs, x0, offset

jr

Assembler pseudo-instruction

Register-indirect jump pseudo-instruction, commonly expanded as jalr x0, 0(rs). It does not save a return address; it only transfers control to the target address held in a register.

jrpseudoinstructionindirect jumpJALRjump tablefunction pointer
Details
You Write
jr rs / jr offset(rs)
Expands To
jalr x0, 0(rs) # or with offset: jalr x0, offset(rs)

tail

Assembler pseudo-instruction

Tail call pseudo-instruction, expands to AUIPC t1 + JALR x0 (no return address saved). It is used when the final action of a function jumps to another function, whose return goes directly to the current function's caller.

tailpseudoinstructiontail callTCOAUIPCtail recursion
Details
You Write
tail symbol
Expands To
auipc t1, offset[31:12] jalr x0, offset[11:0](t1) # t2 may replace t1 when Zicfilp is enabled

neg

Assembler pseudo-instruction

Negate (two's complement) pseudo-instruction, expands to sub rd, x0, rs. Computes 0 - rs to obtain the arithmetic negation of rs. Common for sign flipping, absolute value pre-computation, and subtraction optimization.

negpseudoinstructionnegateSUBtwo's complementsign flip
Details
You Write
neg rd, rs
Expands To
sub rd, x0, rs

not

Assembler pseudo-instruction

Bitwise NOT pseudo-instruction, expands to xori rd, rs, -1. Flips every bit of register rs (0→1, 1→0) and stores in rd. Common for bitmask generation, bit clearing, and logic operations.

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

seqz

Assembler pseudo-instruction

Set if equal zero pseudo-instruction, expands to sltiu rd, rs, 1. Sets rd=1 if rs==0, else rd=0. rd = (rs == 0) ? 1 : 0. Common for null pointer checks and booleanization.

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

snez

Assembler pseudo-instruction

Set if not equal zero pseudo-instruction, expands to sltu rd, x0, rs. Sets rd=1 if rs!=0, else rd=0. rd = (rs != 0) ? 1 : 0. Equivalent to unsigned comparison rs > 0.

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

lga

Assembler pseudo-instruction

Load-global-address pseudo-instruction that obtains a global symbol address through a GOT PC-relative sequence. The official assembly manual gives AUIPC plus LW on RV32 or LD on RV64 as the base form.

lgapseudoinstructionpseudo-instructionassembler aliasglobal addressglobal symbol
Details
You Write
lga rd, symbol
Expands To
.Llga: auipc rd, %got_pcrel_hi(symbol) l{w|d} rd, %pcrel_lo(.Llga)(rd)

lla

Assembler pseudo-instruction

Load-local-address pseudo-instruction that expands, per the official assembly manual, to a PC-relative AUIPC+ADDI sequence. It fits local symbols or non-PIC address paths that do not need GOT indirection.

llapseudoinstructionpseudo-instructionassembler aliaslocal addresslocal symbol
Details
You Write
lla rd, symbol
Expands To
.Llla: auipc rd, %pcrel_hi(symbol) addi rd, rd, %pcrel_lo(.Llla)

sgtz

Assembler pseudo-instruction

Set-if-greater-than-zero pseudo-instruction, expanding to slt rd, x0, rs. If rs is greater than 0 as a signed value, rd=1; otherwise rd=0.

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

sltz

Assembler pseudo-instruction

Set-if-less-than-zero pseudo-instruction, expanding to slt rd, rs, x0. If rs is less than 0 as a signed value, rd=1; otherwise rd=0.

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

csrr

Assembler pseudo-instruction

Read-CSR pseudo-instruction, expanding to csrrs rd, csr, x0. It reads the selected CSR into rd and requests no bit set because rs1=x0.

csrrCSRpseudoinstructioncontrol status registercsrrwcsrrs
Details
You Write
csrr rd, csr
Expands To
csrrs rd, csr, x0

csrw

Assembler pseudo-instruction

Write-CSR pseudo-instruction, expanding to csrrw x0, csr, rs. It writes rs to the CSR and does not read or return the old CSR value because rd=x0.

csrwCSRpseudoinstructioncontrol status registercsrrwcsrrs
Details
You Write
csrw csr, rs
Expands To
csrrw x0, csr, rs

csrc

Assembler pseudo-instruction

Clear-CSR-bits pseudo-instruction, expanding to csrrc x0, csr, rs. It atomically clears CSR bits selected by 1 bits in rs and does not return the old value.

csrcCSRpseudoinstructioncontrol status registercsrrwcsrrs
Details
You Write
csrc csr, rs
Expands To
csrrc x0, csr, rs

csrs

Assembler pseudo-instruction

Set-CSR-bits pseudo-instruction, expanding to csrrs x0, csr, rs. It atomically sets CSR bits selected by 1 bits in rs and does not return the old value.

csrsCSRpseudoinstructioncontrol status registercsrrwcsrrs
Details
You Write
csrs csr, rs
Expands To
csrrs x0, csr, rs

csrci

Assembler pseudo-instruction

Immediate clear-CSR-bits pseudo-instruction, expanding to csrrci x0, csr, uimm. It clears CSR bits selected by 1 bits in the 5-bit immediate and does not return the old value.

csrciCSRpseudoinstructioncontrol status registercsrrwcsrrs
Details
You Write
csrci csr, uimm
Expands To
csrrci x0, csr, uimm

csrsi

Assembler pseudo-instruction

Immediate set-CSR-bits pseudo-instruction, expanding to csrrsi x0, csr, uimm. It sets CSR bits selected by 1 bits in the 5-bit immediate and does not return the old value.

csrsiCSRpseudoinstructioncontrol status registercsrrwcsrrs
Details
You Write
csrsi csr, uimm
Expands To
csrrsi x0, csr, uimm

csrwi

Assembler pseudo-instruction

Immediate write-CSR pseudo-instruction, expanding to csrrwi x0, csr, uimm. It writes the 5-bit unsigned immediate to the CSR and does not return the old value.

csrwiCSRpseudoinstructioncontrol status registercsrrwcsrrs
Details
You Write
csrwi csr, uimm
Expands To
csrrwi x0, csr, uimm

bgez

Assembler pseudo-instruction

Branch-if-greater-or-equal-zero pseudo-instruction, expanding to bge rs, x0, offset. It uses a signed comparison to test whether a register is non-negative, common in sign checks, loop bounds, and error-code tests.

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

bgt

Assembler pseudo-instruction

Signed greater-than branch pseudo-instruction. It swaps the two source registers and uses BLT: bgt rs1, rs2, offset is equivalent to blt rs2, rs1, offset.

bgtpseudoinstructionconditional branchbranchcomparesigned
Details
You Write
bgt rs1, rs2, offset
Expands To
blt rs2, rs1, offset

bgtu

Assembler pseudo-instruction

Unsigned greater-than branch pseudo-instruction. It swaps the two source registers and uses BLTU: bgtu rs1, rs2, offset is equivalent to bltu rs2, rs1, offset.

bgtupseudoinstructionconditional branchbranchcomparesigned
Details
You Write
bgtu rs1, rs2, offset
Expands To
bltu rs2, rs1, offset

bgtz

Assembler pseudo-instruction

Branch-if-greater-than-zero pseudo-instruction, expanding to blt x0, rs, offset. It uses a signed comparison to test whether rs is strictly greater than 0.

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

ble

Assembler pseudo-instruction

Signed less-or-equal branch pseudo-instruction. It swaps source registers and uses BGE: ble rs1, rs2, offset is equivalent to bge rs2, rs1, offset.

blepseudoinstructionconditional branchbranchcomparesigned
Details
You Write
ble rs1, rs2, offset
Expands To
bge rs2, rs1, offset

bleu

Assembler pseudo-instruction

Unsigned less-or-equal branch pseudo-instruction. It swaps source registers and uses BGEU: bleu rs1, rs2, offset is equivalent to bgeu rs2, rs1, offset.

bleupseudoinstructionconditional branchbranchcomparesigned
Details
You Write
bleu rs1, rs2, offset
Expands To
bgeu rs2, rs1, offset

blez

Assembler pseudo-instruction

Branch-if-less-or-equal-zero pseudo-instruction, expanding to bge x0, rs, offset. It uses a signed comparison to test whether rs is not greater than 0.

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

bltz

Assembler pseudo-instruction

Branch-if-less-than-zero pseudo-instruction, expanding to blt rs, x0, offset. It uses a signed comparison to test whether the register is negative.

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

frflags

Assembler pseudo-instruction

Read-fflags pseudo-instruction, expanding to csrrs rd, fflags, x0. fflags holds accrued floating-point exception flags.

frflagsfloating-pointCSRfcsrfrmfflags
Details
You Write
frflags rd
Expands To
csrrs rd, fflags, x0

fsflags

Assembler pseudo-instruction

Write-fflags pseudo-instruction. The common read/write form expands to csrrw rd, fflags, rs; an x0 form does not return old exception flags.

fsflagsfloating-pointCSRfcsrfrmfflags
Details
You Write
fsflags rd, rs / fsflags rs
Expands To
csrrw rd, fflags, rs # or write-only form: csrrw x0, fflags, rs

frcsr

Assembler pseudo-instruction

Read-fcsr pseudo-instruction, expanding to csrrs rd, fcsr, x0. fcsr combines the floating-point rounding mode frm and exception flags fflags.

frcsrfloating-pointCSRfcsrfrmfflags
Details
You Write
frcsr rd
Expands To
csrrs rd, fcsr, x0

frrm

Assembler pseudo-instruction

Read-frm pseudo-instruction, expanding to csrrs rd, frm, x0. frm holds the dynamic floating-point rounding-mode encoding.

frrmfloating-pointCSRfcsrfrmfflags
Details
You Write
frrm rd
Expands To
csrrs rd, frm, x0

fscsr

Assembler pseudo-instruction

Write-fcsr pseudo-instruction. The common read/write form expands to csrrw rd, fcsr, rs and returns the old value in rd; an x0 form does not return the old value.

fscsrfloating-pointCSRfcsrfrmfflags
Details
You Write
fscsr rd, rs / fscsr rs
Expands To
csrrw rd, fcsr, rs # or write-only form: csrrw x0, fcsr, rs

fsflagsi

Assembler pseudo-instruction

Immediate write-fflags pseudo-instruction, expanding to csrrwi rd, fflags, uimm or an x0 form that does not return the old value. It directly writes the floating-point exception flag field.

fsflagsifloating-pointCSRfcsrfrmfflags
Details
You Write
fsflagsi rd, uimm / fsflagsi uimm
Expands To
csrrwi rd, fflags, uimm # or write-only form: csrrwi x0, fflags, uimm

fsrm

Assembler pseudo-instruction

Write-frm pseudo-instruction. The common read/write form expands to csrrw rd, frm, rs; an x0 form does not return the old rounding mode.

fsrmfloating-pointCSRfcsrfrmfflags
Details
You Write
fsrm rd, rs / fsrm rs
Expands To
csrrw rd, frm, rs # or write-only form: csrrw x0, frm, rs

fsrmi

Assembler pseudo-instruction

Immediate write-frm pseudo-instruction, expanding to csrrwi rd, frm, uimm or an x0 form that does not return the old value. uimm is the 5-bit CSR immediate field.

fsrmifloating-pointCSRfcsrfrmfflags
Details
You Write
fsrmi rd, uimm / fsrmi uimm
Expands To
csrrwi rd, frm, uimm # or write-only form: csrrwi x0, frm, uimm

jal

Assembler pseudo-instruction

Omitted-rd form of JAL, expanding to jal ra, offset. It saves the return address in ra for near direct calls within the ±1 MiB JAL range.

jalpseudoinstructionpseudo-instructionassembler aliasfunction calllink
Details
You Write
jal offset
Expands To
jal ra, offset

jalr

Assembler pseudo-instruction

Omitted-operand forms of JALR, commonly defaulting to ra as the link register and offset 0. It is used for indirect calls through a target address held in a register.

jalrpseudoinstructionpseudo-instructionassembler aliasindirect callfunction pointer
Details
You Write
jalr rs / jalr offset(rs) / jalr rd, rs
Expands To
jalr ra, 0(rs) # or with offset: jalr ra, offset(rs) # or with explicit rd: jalr rd, 0(rs)

sext-w

Assembler pseudo-instruction

RV64 sign-extend-word pseudo-instruction, expanding to addiw rd, rs, 0. It takes the low 32 bits of rs and sign-extends bit 31 to XLEN.

sext-wsext.wpseudoinstructionpseudo-instructionassembler aliassign extend
Details
You Write
sext.w rd, rs
Expands To
addiw rd, rs, 0

negw

Assembler pseudo-instruction

RV64 word-negate pseudo-instruction, expanding to subw rd, x0, rs. It negates only the low 32 bits in two’s-complement arithmetic and sign-extends the 32-bit result to XLEN.

negwpseudoinstructionpseudo-instructionassembler aliasword negate32-bit negate
Details
You Write
negw rd, rs
Expands To
subw rd, x0, rs

rdcycle

Assembler pseudo-instruction

Read-cycle-counter pseudo-instruction, expanding to csrrs rd, cycle, x0. It reads the low XLEN bits of the processor cycle counter.

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

rdcycleh

Assembler pseudo-instruction

Read-cycleh-counter pseudo-instruction, expanding to csrrs rd, cycleh, x0. On RV32 it reads the high 32 bits of cycle; RV64 generally does not use the h-suffixed form.

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

rdinstret

Assembler pseudo-instruction

Read-instret-counter pseudo-instruction, expanding to csrrs rd, instret, x0. It reads the low XLEN bits of the retired-instruction counter.

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

rdinstreth

Assembler pseudo-instruction

Read-instreth-counter pseudo-instruction, expanding to csrrs rd, instreth, x0. On RV32 it reads the high 32 bits of instret; RV64 generally does not use the h-suffixed form.

rdinstrethcounterCSRcycletimeinstret
Details
You Write
rdinstreth rd
Expands To
csrrs rd, instreth, x0

rdtime

Assembler pseudo-instruction

Read-time-counter pseudo-instruction, expanding to csrrs rd, time, x0. It reads the low XLEN bits of the platform-provided real-time counter.

rdtimecounterCSRcycletimeinstret
Details
You Write
rdtime rd
Expands To
csrrs rd, time, x0

rdtimeh

Assembler pseudo-instruction

Read-timeh-counter pseudo-instruction, expanding to csrrs rd, timeh, x0. On RV32 it reads the high 32 bits of time; RV64 generally does not use the h-suffixed form.

rdtimehcounterCSRcycletimeinstret
Details
You Write
rdtimeh rd
Expands To
csrrs rd, timeh, x0

zext-b

Assembler pseudo-instruction

Zero-extend-byte pseudo-instruction, expressible per the official assembly manual as andi rd, rs, 255. It keeps the low 8 bits and clears the high bits.

zext-bzext.bpseudoinstructionpseudo-instructionassembler aliaszero extend byte
Details
You Write
zext.b rd, rs
Expands To
andi rd, rs, 255

zext-h

Assembler pseudo-instruction

Zero-extend-halfword pseudo-instruction that keeps the low 16 bits and clears the high bits. Without Zbb it can use a shift-left/logical-shift-right sequence; with Zbb it can use a single instruction form.

zext-hzext.hpseudoinstructionpseudo-instructionassembler aliaszero extend halfword
Details
You Write
zext.h rd, rs
Expands To
# Zbb path zext.h rd, rs # or without Zbb: slli rd, rs, XLEN-16 srli rd, rd, XLEN-16

zext-w

Assembler pseudo-instruction

RV64 zero-extend-word pseudo-instruction that keeps the low 32 bits and clears the high bits. Without Zba it can use an slli/srli sequence; with Zba it can use add.uw.

zext-wzext.wpseudoinstructionpseudo-instructionassembler aliaszero extend
Details
You Write
zext.w rd, rs
Expands To
# RV64+Zba path add.uw rd, rs, x0 # or RV64 without Zba: slli rd, rs, 32 srli rd, rd, 32

pause

Assembler pseudo-instruction

PAUSE hint pseudo-instruction, listed in the official assembly manual as fence w, 0. It is used in spin-wait loops to give implementations an opportunity to reduce resource contention or power.

pausepseudoinstructionpseudo-instructionassembler aliasspin waitlow power
Details
You Write
pause
Expands To
fence w, 0

sbreak

Assembler pseudo-instruction

Older breakpoint pseudo-instruction name, expanding to ebreak. It preserves compatibility with earlier assembly spelling; modern code typically writes EBREAK directly.

sbreakpseudoinstructionpseudo-instructionassembler aliasbreakpointold name
Details
You Write
sbreak
Expands To
ebreak

scall

Assembler pseudo-instruction

Older system-call pseudo-instruction name, expanding to ecall. It preserves compatibility with earlier assembly spelling; modern code typically writes ECALL directly.

scallpseudoinstructionpseudo-instructionassembler aliassystem callold name
Details
You Write
scall
Expands To
ecall

fence-tso

FENCE encoding spelling

fence.tso is a TSO memory-ordering spelling encoded as the FENCE TSO/fm=1000, pred=rw, succ=rw form. It expresses TSO-style ordering and is not merely the ordinary textual form fence rw,rw.

fence-tsofence.tsopseudoinstructionpseudo-instructionassembler aliasTSO
Details
You Write
fence.tso
Encoding Form
fence.tso # FENCE encoding: fm=1000, pred=rw, succ=rw