
Instruction Set
4-219
SCAS
Scan String for Component
SCAS
SCASB Scan String for Byte
SCASW Scan String for Word
What It Does
SCAS compares a component in a string to a register.
Syntax
Description
SCAS subtracts the memory byte or word at the destination index register from the AL or
AX register. The result is discarded and only the flags are set. The operand must be
addressable from the ES segment. No segment override is possible. The contents of the
destination index register determine the address of the memory data being compared, not
the SCAS instruction operand. The operand validates ES segment addressability and
determines the data type. Load the correct index value into the DI register before executing
the SCAS instruction.
After the comparison, the destination index register automatically updates. If the Direction
Flag (DF) is 0 (see CLD on page 4-231), the destination index register increments. If DF
is 1 (see STD on page 4-231), it decrements. The increment or decrement amount is 1 for
bytes or 2 for words.
The SCASB and SCASW instructions are synonyms for the byte and word SCAS
instructions that do not require operands. They are simpler to code, but provide no type or
segment checking.
Form
Opcode
Description
Clocks
Am186 Am188
SCAS
m8
AE
Compare byte AL to ES:[DI]; update DI
15
19
SCAS
m16
AF
Compare word AX to ES:[DI]; update DI
15
19
SCASB
AE
Compare byte AL to ES:[DI]; update DI
15
19
SCASW
AF
Compare word AX to ES:[DI]; update DI
15
19
Regardless of the form of SCAS
you use, destination is always
ES:[DI]. Before using any form of
SCAS, make sure that ES contains
the segment of the string and DI
contains the offset of the string.
To compare AL to a byte within a string
located in the segment specified in
ES, use this form.
To compare AX to a word within a string
located in the segment specified in ES,
use this form.
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.
SCAS
destination
SCASB
SCASW
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...