
Instruction Set
4-237
S T OS
S T OS B S tore S tring Byte
S T OS W S tore S tring Word
S tore S tring Component
S T OS
What It Does
STOS copies a component from a register to a string.
S yntax
Desc ription
STOS transfers the contents of the AL or AX register to the memory byte or word given by
the destination register (DI) relative to the ES segment. The destination operand must be
addressable from the ES register. A segment override is not possible. The contents of the
destination register determine the destination address. STOS does not use an explicit
operand. This operand only validates ES segment addressability and determines the data
type. You must load the correct index value into the destination register before executing
the STOS instruction.
After the transfer, STOS automatically updates the Destination Index (DI) register. If the
Direction Flag (DF) is 0 (see CLD on page 4-29), the register increments. If DF is 1 (see
STD on page 4-231), the register decrements. The increment or decrement amount is 1
for a byte or 2 for a word.
STOSB and STOSW are synonyms for the byte and word STOS instructions. These forms
do not require an operand and are simpler to use, but provide no type or segment checking.
Form
Opcode
Description
Clocks
Am186 Am188
STOS m8
AA
Store AL in byte ES:[DI]; update DI
10
10
STOS m16
AB
Store AX in word ES:[DI]; update DI
10
14
STOSB
AA
Store AL in byte ES:[DI]; update DI
10
10
STOSW
AB
Store AX in word ES:[DI]; update DI
10
14
STOS destination
STOSB
STOSW
To have the assembler type-check
your operand, use this form. The
assembler uses the definition of the
string component to determine which
register to use.
Regardless of the form of STOS
you use, destination is always
ES:[DI]. Before using any form of
STOS, make sure that ES contains
the segment of the string and DI
contains the offset of the string.
To copy AL to a byte within a string
located in the segment specified in
ES, use this form.
To copy AX to a word within a string
located in the segment specified n ES,
use this form.