Compare String                                

86/88

Y

186

Y

286

Y

386

Y

486

Y

CMPS/CMPSB/CMPSW/CMPSD dest,source

Ovfl

Y

Dir

N

Int

N

Trap

N

Sign

Y

Zero

Y

Aux

Y

Prty

Y

Carry

Y

    This instruction compares two values by subtracting the byte or word
    pointed to by ES:DI, from the byte or word pointed to by DS:SI, and
    sets the flags according to the results of the comparison. The
    operands themselves are not altered. After the comparison, SI and DI
    are incremented (if the direction flag is cleared) or decremented (if
    the direction flag is set), in preparation for comparing the next
    element of the string.

    The REP prefixes can be used to process entire data items.

       Note:          This instruction is always translated by the
                      assembler into either CMPSB, Compare String Byte, or
                      CMPSW, Compare String Word, depending upon whether
                      source refers to a string of bytes or words. In
                      either case, you must explicitly load the SI and DI
                      registers with the offset of the source and
                      destination strings.

------------------------------------ Timing ----------------------------------

OpCode          Instruction             386     286     86
A6              CMPS m8, m8             10      8       22
A7              CMPS m16, m16           10      8       22
A7              CMPS m32, m32           10      8
A6              CMPSB                   10      8       22
A7              CMPSW                   10      8       22
A7              CMPSD                   10      8

------------------------------------ Logic -----------------------------------

        CMP [DS:SI], [ES:DI]    ; sets flags only
        if DF = 0
                SI = SI + n
                DI = DI + n
        else
                SI = SI - n
                DI = DI - n

See Also CMP SCAS LODS MOVS STOS REP REPE REPNE CLD STD Flags


Copyright © 1985 to 2022 Beta Systems                            Last modified: Wednesday, January 05, 2022 .