background image

LODS/LODSB/LODSW/LODSD/LODSQ—Load String

INSTRUCTION SET REFERENCE, A-L

Vol. 2A 3-539

In 64-bit mode, use of the REX.W prefix promotes operation to 64 bits. LODS/LODSQ load the quadword at address 
(R)SI into RAX. The (R)SI register is then incremented or decremented automatically according to the setting of 
the DF flag in the EFLAGS register. 
The LODS, LODSB, LODSW, and LODSD instructions can be preceded by the REP prefix for block loads of ECX 
bytes, words, or doublewords. More often, however, these instructions are used within a LOOP construct because 
further processing of the data moved into the register is  usually necessary before the next transfer can be made. 
See “REP/REPE/REPZ /REPNE/REPNZ—Repeat String Operation Prefix” in Chapter 4 of the Intel® 64 and IA-32 
Architectures Software Developer’s Manual, Volume 2B
, for a 
description of the REP prefix.

Operation

IF AL ← SRC; (* Byte load *)

THEN AL ← SRC; (* Byte load *)

IF DF 

0

THEN (E)SI ← (E)SI + 1; 

ELSE (E)SI ← (E)SI – 1; 

FI;

ELSE IF AX ← SRC; (* Word load *)

THEN IF DF 

0

THEN (E)SI ← (E)SI + 2; 

ELSE (E)SI ← (E)SI – 2; 

IF;

FI;

ELSE IF EAX ← SRC; (* Doubleword load *)

THEN IF DF

 = 

0

THEN (E)SI ← (E)SI + 4; 

ELSE (E)SI ← (E)SI – 4; 

FI;

FI;

ELSE IF RAX ← SRC; (* Quadword load *)

THEN IF DF 

=

 0

THEN (R)SI ← (R)SI + 8; 

ELSE (R)SI ← (R)SI – 8; 

FI;

FI;

FI;

Flags Affected

None

Protected Mode Exceptions

#GP(0)

If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
If the DS, ES, FS, or GS register contains a NULL segment selector.

#SS(0)

If a memory operand effective address is outside the SS segment limit.

#PF(fault-code)

If a page fault occurs.

#AC(0)

If alignment checking is enabled and an unaligned memory reference is made while the 

current privilege level is 3.

#UD 

If the LOCK prefix is used.

Real-Address Mode Exceptions

#GP

If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.

#SS

If a memory operand effective address is outside the SS segment limit.

#UD 

If the LOCK prefix is used.