z80:Opcodes:BIT

From Learn @ Cemetech
Jump to navigationJump to search

Tests if the specified bit is set.

Syntax

   bit n,op8

Allowed Instructions

n can be any integer from [0,7]. It must be defined on compile time.

   bit n,a
   bit n,b
   bit n,c
   bit n,d
   bit n,e
   bit n,h
   bit n,l
   bit n,(hl)
   bit n,(ix+n)
   bit n,(iy+n)

Effects

Opposite of the n^^th^^ bit is written into the Z flag. C is preserved, N is reset, H is set, and S and P/V are undefined.


   ld a,%00000001
   bit 0,a		;would reset Z
   bit 1,a		;would set Z


Uses

T-States

r denotes 8-bit register.

r 8
(hl) 12
(ix+X) 20
(iy+X) 20

See Also

AND,CCF,CP,CPD,CPDR,CPI,CPIR,CPL,OR,RES,SCF,SET,XOR