call

RISC-V call Pseudo-Instruction Details

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.

What You Write
call symbol / call rd, symbol
Typical Real Expansion
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)

What This Pseudo Instruction Is Saving You From Writing

JAL's ±1 MiB range is insufficient for far calls; call forms a PC-relative call sequence via AUIPC+JALR for a larger link-time reach, making it common in RISC-V position-independent code (PIC) and dynamic linking.

call primarily means "Far function call". It is assembler-level shorthand; when debugging, auditing, or reading machine code, reason from the real expansion and relocation semantics listed on this page.

Official Semantics Checklist

The official assembly manual treats call as an assembler-level pseudo-instruction or alias; hardware executes the expanded real instruction sequence.
The real semantics come from the ISA definitions of AUIPC and the other expanded instructions, not from a separate call hardware opcode.
For symbolic targets, final machine code can be affected by R_RISCV_CALL/R_RISCV_CALL_PLT relocations and linker relaxation.

Toolchain And Linker Boundaries

Symbolic call targets are normally represented through R_RISCV_CALL or R_RISCV_CALL_PLT-style relocations, and the final code may relax to JAL.
The AUIPC+JALR form shown here is the official common long-call form; use linked disassembly for final machine code.

How To Read The Expansion

Step 1
AUIPC ra, offset[31:12]: adds the upper PC-relative offset to the current PC and stores the intermediate address in ra.
Step 2
JALR ra, offset[11:0](ra): forms the jump target from ra plus the low 12-bit offset, while writing the return address into ra.
Step 3
Explicit-rd variant: AUIPC rd, offset[31:12] first stores the intermediate address in rd; JALR rd, offset[11:0](rd) jumps and writes the return address to rd.

What You May See In objdump / Disassembly

Disassembler shows the AUIPC+JALR pair as call symbol or call rd,symbol. The actual encoding depends on linker relaxation — short distances may be optimized to a single JAL.

Official References And Reading Order

This page treats pseudo-instructions as assembler-level aliases or macros: first read what real instructions they expand to, then use the official ISA manual for the behavior of those real instructions. ABI, relocation, and linker-relaxation details follow the psABI document.

When To Think Of It First

Call functions farther than ±1 MiB
Shared library (.so) function calls via PLT entries
Cross-module calls in position-independent code
Subroutines beyond JAL range in large projects

Pitfalls / Common Confusions

The common expansion occupies two instructions (AUIPC+JALR); the linker may relax reachable targets to a single JAL
Final targets are determined by relocations such as R_RISCV_CALL / R_RISCV_CALL_PLT, not just the offset text in source
Do not hand-rewrite call as ordinary %pcrel_hi/%pcrel_lo address loading — the relocation type is different
call rd, symbol writes the intermediate PC-relative address into rd, clobbering its old value before rd receives the return address

FAQ

Is call a real RISC-V instruction?

call is an assembler pseudo-instruction or alias, not a separate hardware opcode. The “Typical Real Expansion” section lists the official expansion, and behavior is defined by the expanded ISA instructions.

What is the main trap when using call?

The common expansion occupies two instructions (AUIPC+JALR); the linker may relax reachable targets to a single JAL