/// Overflow for ADC and SBC indicates if we overflow from bit 6 to bit 7 of the u8,
/// and change the meaning of a number from being negative or positive.
/// e.g. 0b0111_1111 + 0b0000_0001 = 0b1000_0000
///        |             |             |
///        positive      positive      negative result
Overflow for ADC and SBC indicates if we overflow from bit 6 to bit 7 of the u8,
and change the meaning of a number from being negative or positive.
Overflow for ADC and SBC indicates if we overflow from bit 6 to bit 7 of the u8 and change the meaning of a number from being negative or positive .
fn update_overflow_flag(&mut self, operand: u8, result: u8) {
        let bit_7_mask = 0b1000_0000;
        let does_overflow = (
            // Only look at bit 7, the most significant bit (MSB)
            bit_7_mask &
        // A and operand have the same MSB.
        !(self.a ^ operand) &
        // A and result have a different MSB
        (self.a ^ result)
        ) == bit_7_mask; // Are both conditions correct as commented above?
        self.set_status_flag(StatusFlag::Overflow, does_overflow);
    }
fn update_overflow_flag ( & mut self , operand : u8 , result : u8 ) { let bit_7_mask = 0b1000_0000 ; let does_overflow = ( // Only look at bit 7, the most significant bit (MSB) bit_7_mask & // A and operand have the same MSB. ! ( self . a ^ operand ) & // A and result have a different MSB ( self . a ^ result ) ) == bit_7_mask ; // Are both conditions correct as commented above? self . set_status_flag ( StatusFlag :: Overflow , does_overflow ) ; }
Overflow for ADC and SBC indicates if we overflow from bit 6 to bit 7 of the u8,
and change the meaning of a number from being negative or positive.
Overflow for ADC and SBC indicates if we overflow from bit 6 to bit 7 of the u8 and change the meaning of a number from being negative or positive .
&mut self
operand
u8
result
u8