Intel 64 and IA-32 Architectures Software Developers Manual Volume 2B, Instruction Set Reference, N-Z

4-338 Vol. 2B
INSTRUCTION SET REFERENCE, N-Z
register. These must be loaded correctly before the store string instruction is
executed.
The no-operands form provides “short forms” of the byte, word, doubleword, and
quadword versions of the STOS instructions. Here also ES:(E)DI is assumed to be the
destination operand and AL, AX, or EAX is assumed to be the source operand. The
size of the destination and source operands is selected by the mnemonic: STOSB
(byte read from register AL), STOSW (word from AX), STOSD (doubleword from
EAX).
After the byte, word, or doubleword is transferred from the register to the memory
location, the (E)DI register is incremented or decremented according to the setting of
the DF flag in the EFLAGS register. If the DF flag is 0, the register is incremented; if
the DF flag is 1, the register is decremented (the register is incremented or decre-
mented by 1 for byte operations, by 2 for word operations, by 4 for doubleword oper-
ations).
In 64-bit mode, the default address size is 64 bits, 32-bit address size is supported
using the prefix 67H. Using a REX prefix in the form of REX.W promotes operation on
doubleword operand to 64 bits. The promoted no-operand mnemonic is STOSQ.
STOSQ (and its explicit operands variant) store a quadword from the RAX register
into the destination addressed by RDI or EDI. See the summary chart at the begin-
ning of this section for encoding data and limits.
The STOS, STOSB, STOSW, STOSD, STOSQ 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 data needs to be moved
into the AL, AX, or EAX register before it can be stored. See
“REP/REPE/REPZ/REPNE/REPNZ—Repeat String Operation Prefix” in this chapter for
a description of the REP prefix.
Operation
Non-64-bit Mode:
IF (Byte store)
THEN
DEST AL;
THEN IF DF
= 0
THEN (E)DI (E)DI + 1;
ELSE (E)DI (E)DI – 1;
FI;
ELSE IF (Word store)
THEN
DEST AX;
THEN IF DF
= 0
THEN (E)DI (E)DI + 2;
ELSE (E)DI (E)DI – 2;