Assembly Language & Procedure Calls

a pseudo-instruction

Some things you want to write in assembly are common but a bit awkward to express in the bare instruction set. To keep the programmer comfortable, the assembler offers a few convenient shorthands that look like real instructions but are not: pseudo-instructions. You write the friendly version; the assembler quietly expands it into one or more genuine machine instructions. It is like a phrase your editor auto-expands: you type a shortcut, and the full text appears.

A classic example in RISC-V is mv a0, a1 (move the value of register a1 into a0). The real instruction set has no dedicated move; instead the assembler turns mv a0, a1 into addi a0, a1, 0 (add zero to a1 and store it in a0), which does the same thing. Likewise li a0, 5 (load immediate) might become one addi, and loading a big constant might expand into two instructions. The pseudo-instruction is purely a convenience of the assembler; the processor never sees mv or li, only the real instructions they expand to.

Pseudo-instructions matter because they make assembly far more readable without adding any hardware. They are documented as part of the assembler, not the ISA, so they can differ between toolchains. When you read a disassembly (machine code turned back into text), a good disassembler will often show you the pseudo-instruction so the output stays readable. The honest caveat: do not mistake a pseudo-instruction for a hardware feature. mv is a convenience; addi is the machine.

You write: li t0, 42 # load the constant 42 The assembler emits: addi t0, zero, 42 # add 42 to the always-zero register The processor only ever runs the addi; li never exists in machine code.

li is a pseudo-instruction; it expands into a real instruction (or two for large constants).

Pseudo-instructions belong to the assembler, not the ISA. Two assemblers for the same chip may offer different ones, and they add no new hardware capability.

Also called
pseudo-op假指令