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.
CMPS/CMPSB/CMPSW
   Summary  Detail  Example  Key to Flags
──────────────────────────────────────────────────────────────────────────────
 
Compare String                                   Flags:  O D I T S Z A P C
                                                         ═════════════════
                                                         ±       ± ± ± ± ±
Syntax:  CMPS dest,src
         CMPSB
         CMPSW
 
  Compares two strings. DS:SI must point to the source string and
  ES:DI must point to the destination string (even if operands are
  given). For each comparison, the destination element is subtracted from
  the source element and the flags are updated to reflect the result
  (although the result is not stored). DI and SI are adjusted
  according to the size of the operands and the status of the direction
  flag. They are increased if the direction flag has been cleared with
  CLD or decreased if the direction flag has been set with STD.
 
  If the CMPS form of the instruction is used, operands must be provided
  to indicate the size of the data elements to be processed. A segment
  override can be given for the source (but not for the destination).
  If CMPSB (bytes) or CMPSW (words) is used, the instruction determines
  the size of the data elements to be processed.  Operands are not
  allowed with CMPSB or CMPSW.
 
  CMPS and its variations are usually used with repeat prefixes.
  REPNE (or REPNZ) is used to find the first match between two
  strings. REPE (or REPZ) is used to find the first nonmatch.
  Before the comparison, CX should contain the maximum number of
  elements to compare. After a REPNE CMPS, the zero flag will be
  cleared if no match was found. After a REPE CMPS, the zero
  flag will be set if no nonmatch was found. Otherwise SI and DI
  will point to the element after the first match or nonmatch.
                                    -♦-