The LEA instruction

Load the effective address.

Format of the LEA instruction

InstructionDescription
LEA reg16, memStore the effective address in reg16.

Computes the effective address of the second operand (the source operand) and stores it in the first operand (the destination operand). The source operand is a memory address (the offset part) specified by one of the processor addressing modes; the destination operand is a general-purpose register.

First example: loading the address of a string with an index

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

data segment public                 ; Start of the data segment
    string db "Hello World$"
data ends                           ; End of the data segment

code segment public                 ; Start of the code segment
    assume ds:data, cs:code

    main proc                       ; Start of the main procedure
        mov     ax, seg data        ; Get the data segment address and store it in ax
        mov     ds, ax              ; Pass the data segment address from ax to ds

        mov     si, 6               ; Copy the value 6 into the si register; the pointer points to the letter W
        lea     bx, ds:[string+si]  ; Load the address of string into bx with the offset specified in si

        mov     ax, 4C00h           ; Copy the process termination value into ah and the value into al
        int     21h                 ; Call the interrupt
    main endp                       ; End of the main procedure

code ends                           ; End of the code segment
end main                            ; End of file. The main procedure is the entry point

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Second example: performing arithmetic operations with LEA

Using the lea instruction you can perform addition, but only on condition that the registers are base or index registers, for example si, di, bx, bp. The result can be stored in any general-purpose register.

title Author: Evgeny Sergeevich Dovgopolov

.model small<
.stack 100h

code segment public            ; Start of the code segment
    assume cs:code

    main proc                  ; Start of the main procedure
        mov     bx, 1          ; Copy the value 1 into the bx register
        lea     bx, [bx+1]     ; Increase the value in bx by 1

        mov     bx, 8          ; Copy the value 8 into the bx register
        mov     di, 6          ; Copy the value 6 into the di register
        lea     ax, [bx+di]    ; Compute 8 + 6

        mov     si, 4          ; Copy the value 4 into the si register
        mov     bp, 2          ; Copy the value 2 into the bp register
        lea     di, [si+bp+3]  ; Compute 4 + 2 + 3

        mov     bp, 3          ; Copy the value 3 into the bp register
        mov     si, 5          ; Copy the value 5 into the si register
        lea     bx, [bp+si-1]  ; Compute 3 + 5 - 1

        mov     ax, 4C00h      ; Copy the process termination value into ah and the value into al
        int     21h            ; Call the interrupt
    main endp                  ; End of the main procedure

code ends                      ; End of the code segment
end main                       ; End of file. The main procedure is the entry point

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Processor status flags

CF
No
PF
No
AF
No
ZF
No
SF
No
TF
No
IF
No
DF
No
OF
No