lib/cpu/opcodes.js
function bit (cpu, b, n) {
    const r = n & (1 << b);

    cpu.f &= ~0xe0;
    if (r == 0) cpu.f |= FLAG_Z;
    cpu.f |= FLAG_H;

    return r;
}
function bit (cpu, b, n) {
    const r = n & (1 << b);

    cpu.f &= ~0xe0;
    if (r == 0) cpu.f |= FLAG_Z;
    cpu.f |= FLAG_H;

    return r;
}
function bit ( cpu , b , n ) { const r = n & ( 1 << b ) ; cpu . f &= ~ 0xe0 ; if ( r == 0 ) cpu . f |= FLAG_Z ; cpu . f |= FLAG_H ; return r ; }
Bit Opcodes 
BIT b,r

Description:
Test bit b in register r.

Use with:
b = 0 - 7, r = A, B, C, D, E, H, L, (HL)

Flags affected:
Z - Set if bit b of register r is 0.
N - Reset.
H - Set.
C - Not affected.

Opcodes:
Instruction    Parameters    Opcode    Cycles
BIT            b,A           CB 47     8
BIT            b,B           CB 40     8
BIT            b,C           CB 41     8
BIT            b,D           CB 42     8
BIT            b,E           CB 43     8
BIT            b,H           CB 44     8
BIT            b,L           CB 45     8
BIT            b,(HL)        CB 46     16
Bit Opcodes BIT b r