qa.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
SCAS/SCASB/SCASW
   Summary  Detail  Example  Key to Flags
──────────────────────────────────────────────────────────────────────────────
 
Scan String Flags                                Flags:  O D I T S Z A P C
                                                         ═════════════════
                                                         ±       ± ± ± ± ±
Syntax:  SCAS dest
         SCASB
         SCASW
 
  Scans a string to find a value specified in the accumulator register.
  The string to be scanned is considered the destination and must be
  pointed to by ES:DI (even if an operand is specified).  For each
  element, the destination element is subtracted from the accumulator
  value and the flags are updated to reflect the result (although the
  result is not stored).  DI is adjusted according to the size of the
  operands and the status of the direction flag.  DI is increased if the
  direction flag has been cleared with CLD or decreased if the direction
  flag has been set with STD.
 
  If the SCAS form of the instruction is used, an operand must be
  provided to indicate the size of the data elements to be processed.
  No segment override is allowed.  If SCASB (bytes) or SCASW (words) is
  used, the instruction determines the size of the data elements to be
  processed and whether the element scanned for is in AL, AX.  No
  operand is allowed with SCASB or SCASW.
 
  SCAS and its variations are usually used with repeat prefixes.
  REPNE (or REPNZ) is used to find the first match of the accumula-
  tor value. REPE (or REPZ) is used to find the first nonmatch.
  Before the comparison, CX should contain the maximum number of ele-
  ments to compare. After the comparison, CX will be 0 if no match or
  nonmatch was found. Otherwise SI and DI will point to the element
  after the first match or nonmatch.
                                    -♦-