pub fn add_hl_r16(cpu: &mut CPU, r16: &Reg16) -> u8 {
    let value = cpu.registers.read16(r16);
    let original_hl = cpu.registers.read16(&Reg16::HL);

    let combined = original_hl.wrapping_add(value);

    cpu.registers.write16(&Reg16::HL, combined);

    // No change for Flags::ZERO
    cpu.registers.f.set(Flags::SUBTRACT, false);
    cpu.registers.f.set(
        Flags::HALF_CARRY,
        ((original_hl & 0x0FFF) + (value & 0x0FFF)) > 0x0FFF,
    );
    cpu.registers.f.set(
        Flags::CARRY,
        (u32::from(original_hl) + u32::from(value)) > 0xFFFF,
    );

    8
}
/// ADD 16-bit register with register HL, storing the result in HL.
///
/// Takes 8 cycles.
///
/// # Examples
///
/// ```asm
/// ADD HL, BC ; HL <- HL + BC
/// ```
ADD 16-bit register with register HL, storing the result in HL.
Takes 8 cycles.
ADD 16 - bit register with register HL storing the result in HL . Takes 8 cycles .
pub fn add_hl_r16(cpu: &mut CPU, r16: &Reg16) -> u8 {
    let value = cpu.registers.read16(r16);
    let original_hl = cpu.registers.read16(&Reg16::HL);
    let combined = original_hl.wrapping_add(value);
    cpu.registers.write16(&Reg16::HL, combined);
    // No change for Flags::ZERO
    cpu.registers.f.set(Flags::SUBTRACT, false);
    cpu.registers.f.set(
        Flags::HALF_CARRY,
        ((original_hl & 0x0FFF) + (value & 0x0FFF)) > 0x0FFF,
    );
    cpu.registers.f.set(
        Flags::CARRY,
        (u32::from(original_hl) + u32::from(value)) > 0xFFFF,
    );
    8
}
pub fn add_hl_r16 ( cpu : & mut CPU , r16 : & Reg16 ) -> u8 { let value = cpu . registers . read16 ( r16 ) ; let original_hl = cpu . registers . read16 ( & Reg16 :: HL ) ; let combined = original_hl . wrapping_add ( value ) ; cpu . registers . write16 ( & Reg16 :: HL , combined ) ; // No change for Flags::ZERO cpu . registers . f . set ( Flags :: SUBTRACT , false ) ; cpu . registers . f . set ( Flags :: HALF_CARRY , ( ( original_hl & 0x0FFF ) + ( value & 0x0FFF ) ) > 0x0FFF , ) ; cpu . registers . f . set ( Flags :: CARRY , ( u32 :: from ( original_hl ) + u32 :: from ( value ) ) > 0xFFFF , ) ; 8 }
ADD 16-bit register with register HL, storing the result in HL.
ADD 16 - bit register with register HL storing the result in HL .
cpu
&mut CPU
r16
&Reg16
cpu
&mut CPU
r16
&Reg16
examples
None