lea
Load effective address
Computes the effective address of the memory operand and stores it in the destination register, without accessing memory.
8086 and later
- Effective addressesx86-64 assembly
- Sections, directives and labelsx86-64 assembly
- Memory regions and executable filesx86-64 assembly
- Loopsx86-64 assembly
- Arrays, strings and the string instructionsx86-64 assembly
- call, ret and the System V conventionx86-64 assembly
- Floating point and the x87 stackx86-64 assembly
- syscall and the Linux x86-64 ABIx86-64 assembly
- Sum of an arrayx86-64 assembly
- Length of a stringx86-64 assembly
- Changes no flag
Forms
Operands
reg- A general-purpose register matching the operation’s size, for example
al,ax,eaxorrax. The byte registersah,bh,chanddhcannot be used with a REX prefix, which is required byspl,bpl,sil,dilandr8–r15. mem- A memory location addressed with square brackets, for example
[rbx+8]or[label]. imm- An immediate value encoded in the instruction, written as a number, character or label. Its encoded width and any sign extension depend on the instruction; arithmetic immediates may be sign-extended, while shift counts are used without sign extension.
For example, lea rax, [rbx + rcx*4 + 8] stores that address calculation in rax. The brackets describe the calculation; they do not cause a load. NASM also accepts an absolute constant without brackets, such as lea rax, 0x1000.
In 64-bit mode the address calculation uses 64-bit registers by default, or 32-bit registers with the 32-bit address size; 16-bit addressing is unavailable. The destination independently selects a 16-, 32- or 64-bit result. A narrower destination retains the low bits, and a 32-bit register write clears its upper 32 bits. A 32-bit address calculation stored in a 64-bit destination is zero-extended.
global _start
section .data
value: dq 7
section .text
_start:
mov rax, 12
mov rbx, 5
mov rcx, 3
mov rsi, 9
lea rax, [value]
mov rax, 60 ; syscall 60: exit
xor rdi, rdi
syscall