la

RISC-V la Pseudo-Instruction Details

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.

What You Write
la rd, symbol
Typical Real Expansion
# .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)

What This Pseudo Instruction Is Saving You From Writing

A single source form covers local and global/PIC addresses. The assembler selects the lla or lga-style form from the current options, so the programmer does not manually decide whether GOT indirection is needed.

la primarily means "Load a symbol address by code model". 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 la 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 la hardware opcode.
Address-loading relocations such as %pcrel_hi/%pcrel_lo or %got_pcrel_hi must be read with the pairing rules in the assembly manual and psABI.

Toolchain And Linker Boundaries

la selects an lla-style or lga-style path according to .option pic/nopic and the code model; the final form may also be linker-relaxed.
For symbolic operands, read the relocation records and final disassembly, not only the la spelling in source.

How To Read The Expansion

Step 1
Non-PIC path: AUIPC uses the PC at .Lla as the base to form the high PC-relative part of the symbol address.
Step 2
Non-PIC path: ADDI uses the low 12-bit relocation matched to .Lla to complete the address.
Step 3
PIC path: AUIPC uses the PC at .Lla_got as the base to form the high part of the GOT entry address.
Step 4
PIC path: l{w|d} uses the low 12-bit relocation matched to .Lla_got to load the symbol address from the GOT entry.

What You May See In objdump / Disassembly

Non-PIC corresponds to AUIPC+ADDI, while PIC corresponds to AUIPC plus a GOT load; disassembly may show la, lla/lga, or the real instruction sequence.

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

Get the address of a global variable or static object
Load string-literal, jump-table, or function-symbol addresses
Write assembly that should work in both PIC and non-PIC modes
Let the toolchain choose relocations and GOT usage

Pitfalls / Common Confusions

la loads an address, not the memory value at that address; use lw/ld/flw and related loads to fetch the value
In PIC mode it may load indirectly through the GOT, so do not assume AUIPC+ADDI
The low 12-bit relocation must match the corresponding AUIPC label; do not mix labels in hand-written expansions
The final sequence may be linker-relaxed, so debug using relocations and final disassembly

FAQ

Is la a real RISC-V instruction?

la 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 la?

la loads an address, not the memory value at that address; use lw/ld/flw and related loads to fetch the value