LEA
By Vesper Vei
1 minute read
Table of Contents
LEA (lea)
Basic purpose
LEA (Load Effective Address) is used to compute and load the value of an “effective address expression” rather than access that memory address.
It is essentially an arithmetic instruction, not a memory read instruction.
Instruction format
lea rX, [address_expression]rX = 计算 [ ] 内的表达式Behavioral characteristics
- Does not access memory; only computes addresses
- Commonly used for pointer arithmetic
- Can replace addition and multiplication (commonly used by compilers)
- Can implement the full expression: base + index × scale + displacement
Examples
lea rbx, [rdx + rax*4 + 0x10]; 等效于:rbx = rdx + rax*4 + 0x10Common uses
- Pointer offset calculation
- Struct field offset calculation
- Fast addition/multiplication replacement (e.g.
lea rax, \[rax+rax_2\] = rax_3) - Widely used in compiler optimizations to reduce arithmetic instructions