Logic accumulator ← [DS:eSI] if DF = 0 eSI ← eSI + n ; n = 1 for byte, 2 for word, else ; 4 for dword (386+) eSI ← eSI - n endif
This instruction loads the AL, AX, or EAX register with the memory byte, word, or doubleword pointed to by DS (default) and the source-index register (SI or ESI). After the transfer is made, eSI is automatically incremented (if the direction flag is cleared) or decremented (if the direction flag is set), in preparation for loading the next element of the string.
If the address-size attribute of LODS is 16 bits, SI is used for the source-index register; otherwise the the address-size attribute is 32 bits, and the ESI register will be used.
The source segment can be changed with a segment override.
Note: This instruction is always translated by the assembler into LODSB, Load String Byte, LODSW, Load String Word, or LODSD, Load String Dword, depending upon whether source refers to a string of bytes, words or doublewords. In either case, you must explicitly load the eSI register with the offset of the source string.
LODSB, LODSW, and LODSD are synonyms for the byte, word, and doubleword LODS instructions that do not require an operand. They are simpler to use but provide no type or segment checking.
LODS can be preceded with a REP prefix, but this will continually overwrite the contents of the accumulator; LODS is typically used within a LOOP construct.
Opcode Format AC LODS m8 ; = LODSB AD LODS m16 ; = LODSW AD LODS m32 ; = LODSD