gb-emu-lib/CPU.cpp
unsigned long CPU::AND_HL_(const byte& opCode)
{
    byte HL = m_MMU->Read(m_HL);
    byte result = HL & GetHighByte(m_AF);
    SetHighByte(&m_AF, result);

    if (result == 0x00)
    {
        SetFlag(ZeroFlag);
    }
    else
    {
        ClearFlag(ZeroFlag);
    }

    ClearFlag(SubtractFlag);
    SetFlag(HalfCarryFlag);
    ClearFlag(CarryFlag);

    return 8;
}
/*
    AND (HL) - 0xA6

    The logical AND operation is performed between the byte contained at
    the memory address specified by the HL register  and the byte contained
    in the accumulator. The result is stored in the accumulator.

    8 Cycles

    Flags affected(znhc): z010
*/
AND (HL) - 0xA6
The logical AND operation is performed between the byte contained at
the memory address specified by the HL register  and the byte contained
in the accumulator. The result is stored in the accumulator.

8 Cycles


AND ( HL ) - 0xA6 The logical AND operation is performed between the byte contained at the memory address specified by the HL register and the byte contained in the accumulator . The result is stored in the accumulator . 8 Cycles
unsigned long CPU::AND_HL_(const byte& opCode)
{
    byte HL = m_MMU->Read(m_HL);
    byte result = HL & GetHighByte(m_AF);
    SetHighByte(&m_AF, result);
    if (result == 0x00)
    {
        SetFlag(ZeroFlag);
    }
    else
    {
        ClearFlag(ZeroFlag);
    }
    ClearFlag(SubtractFlag);
    SetFlag(HalfCarryFlag);
    ClearFlag(CarryFlag);
    return 8;
}
unsigned long CPU :: AND_HL_ ( const byte & opCode ) { byte HL = m_MMU -> Read ( m_HL ) ; byte result = HL & GetHighByte ( m_AF ) ; SetHighByte ( & m_AF , result ) ; if ( result == 0x00 ) { SetFlag ( ZeroFlag ) ; } else { ClearFlag ( ZeroFlag ) ; } ClearFlag ( SubtractFlag ) ; SetFlag ( HalfCarryFlag ) ; ClearFlag ( CarryFlag ) ; return 8 ; }
AND (HL) - 0xA6
The logical AND operation is performed between the byte contained at
the memory address specified by the HL register  and the byte contained
in the accumulator.
AND ( HL ) - 0xA6 The logical AND operation is performed between the byte contained at the memory address specified by the HL register and the byte contained in the accumulator .