LODSB | The byte from the address <DS:ESI> is loaded in AL If DF=0 then inc(ESI), else dec(ESI) |
LODSW | The word from the address <DS:ESI> is loaded in AX f DF=0 then ESI:=ESI+2, else ESI:=ESI-2 |
LODSD | The double word from the address <DS:ESI> is loaded in EAX If DF=0 then ESI:=ESI+4, else ESI:=ESI-4 |
STOSB | Store AL into the byte from the address <ES:EDI> If DF=0 then inc(EDI), else dec(EDI) |
STOSW | Store AX into the word from the address <ES:EDI> If DF=0 then EDI:= EDI+2, else EDI:= EDI-2 |
STOSD | Store EAX into the double word from the address <ES:EDI> If DF=0 then EDI:= EDI+4, else EDI:= EDI-4 |
MOVSB | Store the byte from the address <DS:ESI> to the address <ES:EDI> If DF=0 then inc(SI), inc(DI), else dec(SI), dec(DI) |
MOVSW | Store the word from the address <DS:ESI> to the address <ES:EDI> If DF=0 then ESI:= ESI+2, EDI:= EDI+2, else ESI:= ESI-2, EDI:= EDI-2 |
MOVSD | Store the double word from the address <DS:ESI> to the address <ES:EDI> If DF=0 then ESI:= ESI+4, EDI:= EDI+4, else ESI:= ESI-4, EDI:= EDI-4 |
- Obs. Considering the use of the flat memory model, at any start of the program execution, the OS will initialize with the same value the segment registers DS = ES. The programmer has no responsibility in what concerns loading / updating / modifying these values. In the source code that uses the instructions on strings the programmer will only need to manage the offset of these strings.
Example:
;We have a source string of words. Copy this string into another string. We assume we know the length of this string.
mov ECX, dim_sir ; no of elements in string
mov ESI, sir_sursa ; load offset sir_sursa in ESI
mov EDI, sir_dest ; load offset sir_dest in EDI
CLD
Again:
LODSW
STOSW
LOOP Again
- Considering that LODS + STOS = MOVS the above loop is equivalent to:
Again:
MOVSW
LOOP Again
- or (see the prefix instruction section below)
rep MOVSW