Cpd compare and decrement (byte) – Zilog Z80380 User Manual

Page 70

Advertising
background image

5-36

Z380

U

SER

'

S

M

ANUAL

DC-8297-03

Z

ILOG

CPD
COMPARE AND DECREMENT (BYTE)

CPD

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 decremented by one, thus moving the pointer to the previous 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

CPD

11101101 10101001

3+r

X

Advertising