beautypg.com

Cpi compare and increment (byte) – Zilog Z80380 User Manual

Page 72

background image

5-38

Z380

U

SER

'

S

M

ANUAL

DC-8297-03

Z

ILOG

CPI
COMPARE AND INCREMENT (BYTE)

CPI

Operation:

A - (HL)
if (XM) then begin

HL(31-0)

HL(31-0) + 1

end

else begin

HL(15-0)

HL(15-0) + 1

end

BC(15-0)

BC(15-0) - 1

This instruction is used for searching strings of byte data. The byte of data at the location
addressed by the HL register is compared with the contents of the accumulator and the Sign
and Zero flags are set to reflect the result of the comparison. The contents of the accumulator
and the memory bytes are unaffected. Two’s complement subtraction is performed. Next the
HL register is incremented by one, thus moving the pointer to the next element in the string.
The BC register, used as a counter, is then decremented by one.

Flags:

S: Set if the result is negative; cleared otherwise
Z: Set if the result is zero, indicating that the contents of the accumulator and the memory
byte are equal; cleared otherwise
H: Set if there is a borrow from bit 4 of the result; cleared otherwise
V: Set if the result of decrementing BC is not equal to zero; cleared otherwise
N: Set
C: Unaffected

Addressing

Execute

Mode

Syntax

Instruction Format

Time

Note

CPI

11101101 10100001

3+r

X