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

Intel's reference: LEA

CFPFAFZFSFDFOF –––––––
  • Changes no flag

Forms

Operands

reg
A general-purpose register matching the operation’s size, for example al, ax, eax or rax. The byte registers ah, bh, ch and dh cannot be used with a REX prefix, which is required by spl, bpl, sil, dil and r8–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