
Instruction Set
4-36
CMPS
Compare String Components
CMPS
CMPSB Compare String Bytes
CMPSW Compare String Words
What It Does
CMPS compares a component in one string to a component in another string.
Syntax
Description
CMPS compares the byte or word pointed to by the SI register with the byte or word pointed
to by the DI register. You must preload the registers before executing CMPS.
CMPS subtracts the DI indexed operand from the SI indexed operand. No result is stored;
only the flags reflect the change. The operand size determines whether bytes or words are
compared. The first operand (SI) uses the DS register unless a segment override byte is
present. The second operand (DI) must be addressable from the ES register; no segment
override is possible. After the comparison, both the source-index register and the
destination-index register are automatically advanced. If DF is 0, the registers increment
according to the operand size (byte=1; word=2); if DF is 1, the registers decrement.
CMPSB and CMPSW are synonymous with the byte and word CMPS instructions,
respectively.
Form
Opcode
Description
Clocks
Am186 Am188
CMPS
m8,m8
A6
Compare byte ES:[DI] to byte segment:[SI]
22
22
CMPS
m16,m16
A7
Compare word ES:[DI] to word segment:[SI]
22
26
CMPSB
A6
Compare byte ES:[DI] to byte DS:[SI]
22
22
CMPSW
A7
Compare word ES:[DI] to word DS:[SI]
22
26
CMPS
source,destination
CMPSB
CMPSW
To override the default source
segment (DS) and to have the
assembler type-check your operands,
use this form. In this form, source is
segment
:[SI]. The assembler uses the
segment in DS unless you specify a
different segment register as part of
the source string component. The
assembler uses the definitions of the
string components to determine their
sizes.
Regardless of the form of CMPS
you use, destination is always
ES:[DI]. Before using any form of
CMPS, make sure that: ES
contains the segment of the
destination string, DI contains
the offset of the destination
string, and SI contains the offset
of the source string.
To compare a byte within a string
located in the destination segment
specified in ES to a byte within a string
located in the source segment
specified in DS, use this form.
To compare a word within a string
located in the destination segment
specified in ES to a word within a string
located in the source segment
specified in DS, use this form.
Summary of Contents for Am186 Series
Page 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Page 10: ...Table of Contents x...
Page 18: ...Programming 1 8...
Page 40: ...Instruction Set Listing 3 14...