pub fn jump_relative_conditional_d8(cpu: &mut CPU, opcode: u8) -> u8 {
    // Read signed 8-bit jump offset
    let jump_offset: i8 = cpu.fetch8() as i8;

    // Test if the condition matches and if we need to jump
    if opcode_flag_test(opcode, cpu.registers.f) {
        // Jump PC to that target address
        cpu.registers.pc = cpu.registers.pc.wrapping_add(jump_offset as u16);

        12
    } else {
        8
    }
}
/// Jump to a different relative address by adding the 8-bit operand to the current PC register if
/// a given flag status condition matches.
///
/// Takes 12 cycles if condition matches, 8 if it doesn't match.
///
/// # Examples
///
/// ```asm
/// JR NZ $DA ; IF !Flags::RegisterFlags::ZERO { PC <- PC + $DA }
/// ```
Jump to a different relative address by adding the 8-bit operand to the current PC register if
a given flag status condition matches.

Takes 12 cycles if condition matches, 8 if it doesn't match.
Jump to a different relative address by adding the 8 - bit operand to the current PC register if a given flag status condition matches . Takes 12 cycles if condition matches 8 if it doesn ' t match .
pub fn jump_relative_conditional_d8(cpu: &mut CPU, opcode: u8) -> u8 {
    // Read signed 8-bit jump offset
    let jump_offset: i8 = cpu.fetch8() as i8;
    // Test if the condition matches and if we need to jump
    if opcode_flag_test(opcode, cpu.registers.f) {
        // Jump PC to that target address
        cpu.registers.pc = cpu.registers.pc.wrapping_add(jump_offset as u16);
        12
    } else {
        8
    }
}
pub fn jump_relative_conditional_d8 ( cpu : & mut CPU , opcode : u8 ) -> u8 { // Read signed 8-bit jump offset let jump_offset : i8 = cpu . fetch8 ( ) as i8 ; // Test if the condition matches and if we need to jump if opcode_flag_test ( opcode , cpu . registers . f ) { // Jump PC to that target address cpu . registers . pc = cpu . registers . pc . wrapping_add ( jump_offset as u16 ) ; 12 } else { 8 } }
Jump to a different relative address by adding the 8-bit operand to the current PC register if
a given flag status condition matches.
Jump to a different relative address by adding the 8 - bit operand to the current PC register if a given flag status condition matches .
cpu
&mut CPU
opcode
u8
cpu
&mut CPU
opcode
u8
examples
None