IA-32 Assembly Language Reference Manual

The Load String Operand (lods)

lods{bwl}
Operation

load ES:[(E)DI] -> [AL|AX|EAX]

Description

Loads the memory byte or word addressed in the destination register into the AL, AX, or EAX register. Before executing the lods instruction, load the index values into the SI source-index register.

After the data is loaded, the source-index register is automatically incremented or decremented as determined by the value of the direction flag (DF). The index register is incremented if DF = 0 (DF cleared by a cld instruction); it is decremented if DF = 1 (DF set by a std instruction). The increment/decrement count is 1 for a byte move, 2 for a word, and 4 for a long.

For a block transfer of CX bytes, words or longs, precede a lods instruction with a rep prefix; however, lods is used more typically within a loop construct where further processing of the data moved into AL, AX, or EAX is usually required.

Example

Load the memory byte addressed in the destination register, relative to the ES segment register, into the AL register.

lodsb

Load the memory word addressed in the destination register, relative to the ES segment register, into the AX register.

lodsw

Load the memory double-word addressed in the destination register, relative to the ES segment register, into the EAX register.

lodsl