pub fn load_indirect_a16_r16(cpu: &mut CPU, r16_source: &Reg16) -> u8 {
    // Read 16-bit address
    let a16_addr = cpu.fetch16();

    // Split 16-bit register to low/high
    let r16_value = cpu.registers.read16(r16_source);
    let r16_high = ((r16_value & 0xFF00) >> 8) as u8;
    let r16_low = (r16_value & 0x00FF) as u8;

    // Write the two bytes to memory
    cpu.mmu.write8(a16_addr, r16_low);
    cpu.mmu.write8(a16_addr + 1, r16_high);

    20
}
/// Load memory, using a 16-bit register as an address, with an 8-bit register value.
///
/// Takes 20 cycles.
///
/// # Examples
///
/// ```asm
/// LD ($8000), SP ; memory[0x8000] <- SP
/// ```
Load memory, using a 16-bit register as an address, with an 8-bit register value.
Takes 20 cycles.
Load memory using a 16 - bit register as an address with an 8 - bit register value . Takes 20 cycles .
pub fn load_indirect_a16_r16(cpu: &mut CPU, r16_source: &Reg16) -> u8 {
    // Read 16-bit address
    let a16_addr = cpu.fetch16();
    // Split 16-bit register to low/high
    let r16_value = cpu.registers.read16(r16_source);
    let r16_high = ((r16_value & 0xFF00) >> 8) as u8;
    let r16_low = (r16_value & 0x00FF) as u8;
    // Write the two bytes to memory
    cpu.mmu.write8(a16_addr, r16_low);
    cpu.mmu.write8(a16_addr + 1, r16_high);
    20
}
pub fn load_indirect_a16_r16 ( cpu : & mut CPU , r16_source : & Reg16 ) -> u8 { // Read 16-bit address let a16_addr = cpu . fetch16 ( ) ; // Split 16-bit register to low/high let r16_value = cpu . registers . read16 ( r16_source ) ; let r16_high = ( ( r16_value & 0xFF00 ) >> 8 ) as u8 ; let r16_low = ( r16_value & 0x00FF ) as u8 ; // Write the two bytes to memory cpu . mmu . write8 ( a16_addr , r16_low ) ; cpu . mmu . write8 ( a16_addr + 1 , r16_high ) ; 20 }
Load memory, using a 16-bit register as an address, with an 8-bit register value.
Load memory using a 16 - bit register as an address with an 8 - bit register value .
cpu
&mut CPU
r16_source
&Reg16
cpu
&mut CPU
r16_source
&Reg16
examples
None