CMPS COMPARE STRING CMPS
(BYTE OR WORD)
Operation: | Flags Affected: |
(LSRC) - (RSRC) | AF, CF, OF, PF, SF, ZF |
if (OF) = 0 then |
|
(SI) +- (SI) + OELTA |
|
(01) +- (01) + OELTA |
|
else |
|
(SI) +- (SI) - OELTA |
|
(01) +- (01) - OELTA |
|
Description:
eM PS destination-string, source-string
CMPS (Compare String) subtracts the destina- tion byte or word (addressed by DI) from the source byte or word (addressed by SI). CMPS affects the flags but does not alter either operand, updates SI and DI to point to the next string element and updates, AF, CF, OF, PF, SF and ZF to reflect the relationship of the destination element to the source element. For example, if a JG (Jump if Greater) instruction follows CMPS, the jump is taken if the des-
tination element is greater than the source element. If CMPS is prefixed with REPE or REPZ, the operation is interrupted as "com- pare while not
Encoding:
11010011wl
if w = 0 then LSRC = (SI), RSRC = (01), OELTA = 1
else LSRC = (SI) + 1:(SI), RSRC = (01) + 1:(01), OELTA = 2
CMPS Operands | Clocks· | Transfers | Bytes | CMPS Coding Examples |
22(30) | 2 | 1 | CMPSBUFF1, BUFF2 | |
(repeat) | 9+22(30)/rep | 2/rep | 1 | REP COMPS 10, KEY |
*b(w): where b denotes the number of clock cycles for byte operands and w denotes the number of clock cycles for word operands.