INSTRUCTION SET DESCRIPTIONS

Table C-4. Instruction Set (Continued)

Name

Description

Operation

Flags

Affected

 

 

 

 

 

 

 

CMP

Compare:

(dest) – (src)

AF

 

CMP dest, src

 

CF

 

 

DF –

 

Subtracts the source from the desti-

 

 

 

IF –

 

nation, which may be bytes or words,

 

 

 

OF

 

but does not return the result. The

 

 

 

PF

 

operands are unchanged, but the flags

 

 

 

SF

 

are updated and can be tested by a

 

 

 

TF –

 

subsequent conditional jump

 

 

 

ZF ¸

 

instruction. The comparison reflected

 

 

 

in the flags is that of the destination to

 

 

 

the source. If a CMP instruction is

 

 

 

followed by a JG (jump if greater)

 

 

 

instruction, for example, the jump is

 

 

 

taken if the destination operand is

 

 

 

greater than the source operand.

 

 

 

Instruction Operands:

 

 

 

CMP reg, reg

 

 

 

CMP reg, mem

 

 

 

CMP mem, reg

 

 

 

CMP reg, immed

 

 

 

CMP mem, immed

 

 

 

CMP accum, immed

 

 

 

 

 

 

CMPS

Compare String:

(dest-string)(src-string)

AF

 

CMPS dest-string,src-string

if

CF

 

(DF) = 0

DF –

 

Subtracts the destination byte or word

 

then

IF –

 

from the source byte or word. The

 

(SI) (SI) + DELTA

OF

 

destination byte or word is addressed

 

(DI) (DI) + DELTA

PF

 

by the destination index (DI) register

 

else

SF

 

and the source byte or word is

 

(SI) (SI) – DELTA

TF –

 

addresses by the source index (SI)

 

(DI) (DI) – DELTA

ZF ¸

 

register. CMPS updates the flags to

 

 

 

reflect the relationship of the

 

 

 

destination element to the source

 

 

 

element but does not alter either

 

 

 

operand and updates SI and DI to

 

 

 

point to the next string element.

 

 

 

Instruction Operands:

 

 

 

CMP dest-string, src-string

 

 

 

CMP (repeat) dest-string, src-string

 

 

 

 

 

 

NOTE: The three symbols used in the Flags Affected column are defined as follows:

the contents of the flag remain unchanged after the instruction is executed ¸? the contents of the flag is undefined after the instruction is executed

the flag is updated after the instruction is executed

C-10

Page 333
Image 333
Intel 80C186XL, 80C188XL user manual CMP dest, src, Compare String, Cmps dest-string,src-string