BIT b,(HL)

Operation

     _____
Z <- (HL)b

Mnemonic

BIT

Operands

b,(HL)

b7b6b5b4b3b2b1b0
1 1 0 0 1 0 1 1$CB
0 1 b 1 1 0

Description

This instruction tests bit b in the memory location specified by the contents of the HL register pair and sets the Z flag accordingly. In the assembled object code, operand b is specified as follows:

Bit TestedHex
0000$46
1001$4E
2010$56
3011$5E
4100$66
5101$6E
6110$76
7111$7E

Condition Bits Affected

Sis unknown.
Zis set if specified bit is 0, otherwise it is reset.
His set.
P/Vis unknown
Nis reset.
Cis not affected.

Example

If the HL register pair contains $4444, and bit 4 in the memory location $4444 contains 1, then upon the execution of

	BIT	4,(HL)

the Z flag in the F Register contains 0, and bit 4 in memory location 4444h remains at 1. Bit 0 in memory location 4444h is the least-significant bit.