bit
Test bit
Tests one bit of a register or memory byte and sets Z when that bit is zero.
Used in
- 8-bit and 16-bit arithmetic, logic and bitsZ80 assembly
- The screen, keyboard and mouse through portsZ80 assembly
- Even or odd, count the set bits, multiply by shiftingZ80 assembly
- Flappy birdZ80 assembly
SZHP/VNC ?●1?0–
- ● set from the result
- 0 always 0
- 1 always 1
- ? undefined afterwards
- – not changed
Forms
-
Tests bit
bofr. -
Tests bit
bof (HL). -
Tests bit
bof the memory location pointed to by IX plusdd.
Operands
b- A bit number from
0to7, where bit0is the least significant bit. r- An 8-bit register:
a,b,c,d,e,horl. (hl)- The byte in memory at the address stored in
hl. More (ix+dd)- The byte in memory at
ix + dd, whereddis a signed displacement from-128to127, for example(ix+5)or(ix-3).(iy+dd)works the same way. More
.org 0x8000
ld b, 3
bit 0, b
halt