pub fn alu_add_8bit(accumulator: u8, flags: Flags, d8: u8, use_carry: bool) -> (u8, Flags) {
    let cy = if use_carry && flags.contains(Flags::CARRY) {
        1
    } else {
        0
    };

    let big_accumulator: u16 = accumulator as u16 + d8 as u16 + cy as u16;
    let result = big_accumulator as u8;

    let mut new_flags = flags;
    new_flags.set(Flags::ZERO, result == 0);
    new_flags.set(Flags::SUBTRACT, false);
    new_flags.set(
        Flags::HALF_CARRY,
        ((accumulator & 0x0F) + (d8 & 0x0F) + cy) > 0x0F,
    );
    new_flags.set(Flags::CARRY, big_accumulator > 0xFF);

    (result, new_flags)
}
/// Add 8-bit value with register A, storing the result in A.
/// If use_carry is true this will add the content of the carry flag along with the value and take
/// that into account when updating flags too.
///
/// Update flags:
///
/// ## Flags::ZERO
///
/// Set if the result equals zero.
///
/// ## Flags::SUBTRACT
///
/// Always unset
///
/// ## Flags::HALF_CARRY
///
/// Set if the lower nibble of the value added to the lower nibble of A was too large to fit in a u4
///
/// ## Flags::CARRY
///
/// Set if the value added to A would have been too large to fit in a u8
///
Add 8-bit value with register A, storing the result in A.
If use_carry is true this will add the content of the carry flag along with the value and take
that into account when updating flags too.

Update flags.
Add 8 - bit value with register A storing the result in A . If use_carry is true this will add the content of the carry flag along with the value and take that into account when updating flags too . Update flags .
pub fn alu_add_8bit(accumulator: u8, flags: Flags, d8: u8, use_carry: bool) -> (u8, Flags) {
    let cy = if use_carry && flags.contains(Flags::CARRY) {
        1
    } else {
        0
    };
    let big_accumulator: u16 = accumulator as u16 + d8 as u16 + cy as u16;
    let result = big_accumulator as u8;
    let mut new_flags = flags;
    new_flags.set(Flags::ZERO, result == 0);
    new_flags.set(Flags::SUBTRACT, false);
    new_flags.set(
        Flags::HALF_CARRY,
        ((accumulator & 0x0F) + (d8 & 0x0F) + cy) > 0x0F,
    );
    new_flags.set(Flags::CARRY, big_accumulator > 0xFF);
    (result, new_flags)
}
pub fn alu_add_8bit ( accumulator : u8 , flags : Flags , d8 : u8 , use_carry : bool ) -> ( u8 , Flags ) { let cy = if use_carry && flags . contains ( Flags :: CARRY ) { 1 } else { 0 } ; let big_accumulator : u16 = accumulator as u16 + d8 as u16 + cy as u16 ; let result = big_accumulator as u8 ; let mut new_flags = flags ; new_flags . set ( Flags :: ZERO , result == 0 ) ; new_flags . set ( Flags :: SUBTRACT , false ) ; new_flags . set ( Flags :: HALF_CARRY , ( ( accumulator & 0x0F ) + ( d8 & 0x0F ) + cy ) > 0x0F , ) ; new_flags . set ( Flags :: CARRY , big_accumulator > 0xFF ) ; ( result , new_flags ) }
Add 8-bit value with register A, storing the result in A.
Add 8 - bit value with register A storing the result in A .
accumulator
u8
flags
Flags
d8
u8
use_carry
bool
accumulator
u8
flags
Flags
d8
u8
use_carry
bool
flags::zero
Set if the result equals zero.
Set if the result equals zero .
flags::subtract
None
flags::half_carry
Set if the lower nibble of the value added to the lower nibble of A was too large to fit in a u4
Set if the lower nibble of the value added to the lower nibble of A was too large to fit in a u4
flags::carry
Set if the value added to A would have been too large to fit in a u8
Set if the value added to A would have been too large to fit in a u8