SCAS
SCAN (BYTE
OR
WORD) STRING
SCAS
Operation:
(LSRC)
-
(RSRC)
if
(OF)
= 0 then (01)
~
(01) +
OEL
TA
else (01)
~
(01) -
OEL
TA
Description:
seAS
destination-string
SCAS (Scan String) subtracts the destination
string element (byte
or
word) addressed by DI
from the content
of
AL (byte string) or AX
(word string) and updates the flags, but does
not alter the destination string
or
the accum-
ulator. SCAS also updates DI to point to the
next string element and AF, CF,
OF,
PF,
SF
and
ZF to reflect the relationship
of
the scan
value in
ALI
AX
to the string element.
If
Encoding:
11010111wl
Flags
Affected:
AF,CF,OF,PF,SF,ZF
SCAS
is
prefixed with
REPE
or
REPZ,
the
operation
is
interpreted as
"scan
while not
end-of-string (CX
not
0)
and string-element =
scan-value (ZF =
1)."
This form may be used
to scan for departure from a given value.
If
SCAS
is
prefixed with
REPNE
or
REPNZ,
the
operation
is
interpreted as
"scan
while not
end-of -string (CX
not
0)
and string-element
is
not equal to scan-value (ZF =
0)."
This form
may be used to locate a value in a string.
if w = 0 then LSRC = AL, RSRC = (01),
OEL
TA = 1
else LSRC = AX,
RSRC
= (01) + 1 :(01),
OEL
TA = 2
SCAS Operands
Clocks*
Transfers Bytes
SCAS Coding Example
dest-string
15(19)
1 1
SeAS INPUT
_LINE
(repeat) dest-string
9 + 15(19)/rep
1/rep
1
REPNE SeAS BUFFER
*b(w): where b denotes the number of
clock cycles for byte operands and
w denotes the number of
clock cycles for word operands.
2-149