added idy addressing
This commit is contained in:
parent
394d198a0b
commit
72796e6c21
|
@ -34,14 +34,14 @@ impl CPU
|
||||||
|
|
||||||
self.fetch_type = FetchType::Mem;
|
self.fetch_type = FetchType::Mem;
|
||||||
|
|
||||||
print!("{: <30}", format!("${:04X}", self.absolute_addr));
|
print!("{: <40}", format!("${:04X}", self.absolute_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn acc(&mut self)
|
pub fn acc(&mut self)
|
||||||
{
|
{
|
||||||
self.fetch_type = FetchType::Acc;
|
self.fetch_type = FetchType::Acc;
|
||||||
|
|
||||||
print!("{: <30}", "A");
|
print!("{: <40}", "A");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn idx(&mut self)
|
pub fn idx(&mut self)
|
||||||
|
@ -58,7 +58,24 @@ impl CPU
|
||||||
self.absolute_addr = (hi << 8) | lo;
|
self.absolute_addr = (hi << 8) | lo;
|
||||||
self.fetch_type = FetchType::Mem;
|
self.fetch_type = FetchType::Mem;
|
||||||
|
|
||||||
print!("{: <30}", format!("(${:02X},X) @ [${:02X}] = ${:04X} = {:02X}", zpg_addr.wrapping_sub(self.x), zpg_addr, self.absolute_addr, bus.borrow().read_cpu(self.absolute_addr)));
|
print!("{: <40}", format!("(${:02X},X) @ [${:02X}] = ${:04X} = {:02X}", zpg_addr.wrapping_sub(self.x), zpg_addr, self.absolute_addr, bus.borrow().read_cpu(self.absolute_addr)));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn idy(&mut self)
|
||||||
|
{
|
||||||
|
let bus = self.bus.upgrade().unwrap();
|
||||||
|
|
||||||
|
let zpg_addr = bus.borrow().read_cpu(self.pc);
|
||||||
|
self.pc += 1;
|
||||||
|
|
||||||
|
let lo = bus.borrow().read_cpu(zpg_addr as u16) as u16;
|
||||||
|
let hi = bus.borrow().read_cpu(zpg_addr.wrapping_add(1) as u16) as u16;
|
||||||
|
|
||||||
|
let target_addr = (hi << 8) | lo;
|
||||||
|
self.absolute_addr = target_addr.wrapping_add(self.y as u16);
|
||||||
|
self.fetch_type = FetchType::Mem;
|
||||||
|
|
||||||
|
print!("{: <40}", format!("(${:02X}),Y @ [${:04X} + Y] = ${:04X} = {:02X}", zpg_addr, target_addr, self.absolute_addr, bus.borrow().read_cpu(self.absolute_addr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn imm(&mut self)
|
pub fn imm(&mut self)
|
||||||
|
@ -70,12 +87,12 @@ impl CPU
|
||||||
|
|
||||||
self.fetch_type = FetchType::Mem;
|
self.fetch_type = FetchType::Mem;
|
||||||
|
|
||||||
print!("{: <30}", format!("#${:02X}", bus.borrow().read_cpu(self.absolute_addr)));
|
print!("{: <40}", format!("#${:02X}", bus.borrow().read_cpu(self.absolute_addr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn imp(&mut self)
|
pub fn imp(&mut self)
|
||||||
{
|
{
|
||||||
print!("{: <30}", "");
|
print!("{: <40}", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rel(&mut self)
|
pub fn rel(&mut self)
|
||||||
|
@ -85,7 +102,7 @@ impl CPU
|
||||||
self.relative_addr = bus.borrow().read_cpu(self.pc) as i8;
|
self.relative_addr = bus.borrow().read_cpu(self.pc) as i8;
|
||||||
self.pc += 1;
|
self.pc += 1;
|
||||||
|
|
||||||
print!("{: <30}", format!("${:02X}", self.relative_addr));
|
print!("{: <40}", format!("${:02X}", self.relative_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn zpg(&mut self)
|
pub fn zpg(&mut self)
|
||||||
|
@ -97,6 +114,6 @@ impl CPU
|
||||||
|
|
||||||
self.fetch_type = FetchType::Mem;
|
self.fetch_type = FetchType::Mem;
|
||||||
|
|
||||||
print!("{: <30}", format!("${:02X} = {:02X}", self.absolute_addr, bus.borrow().read_cpu(self.absolute_addr)))
|
print!("{: <40}", format!("${:02X} = {:02X}", self.absolute_addr, bus.borrow().read_cpu(self.absolute_addr)))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -523,7 +523,7 @@ pub static INSTRUCTION_SET: [Option<Instruction>; 256] = [
|
||||||
/* 0B */ Option::None,
|
/* 0B */ Option::None,
|
||||||
/* 0C */ Option::None,
|
/* 0C */ Option::None,
|
||||||
/* 0D */ instr!(ora, abs, 4),
|
/* 0D */ instr!(ora, abs, 4),
|
||||||
/* 0E */ Option::None,
|
/* 0E */ instr!(asl, abs, 6),
|
||||||
/* 0F */ Option::None,
|
/* 0F */ Option::None,
|
||||||
|
|
||||||
/* 10 */ instr!(bpl, rel, 2),
|
/* 10 */ instr!(bpl, rel, 2),
|
||||||
|
@ -557,7 +557,7 @@ pub static INSTRUCTION_SET: [Option<Instruction>; 256] = [
|
||||||
/* 2B */ Option::None,
|
/* 2B */ Option::None,
|
||||||
/* 2C */ instr!(bit, abs, 4),
|
/* 2C */ instr!(bit, abs, 4),
|
||||||
/* 2D */ instr!(and, abs, 4),
|
/* 2D */ instr!(and, abs, 4),
|
||||||
/* 2E */ Option::None,
|
/* 2E */ instr!(rol, abs, 6),
|
||||||
/* 2F */ Option::None,
|
/* 2F */ Option::None,
|
||||||
|
|
||||||
/* 30 */ instr!(bmi, rel, 2),
|
/* 30 */ instr!(bmi, rel, 2),
|
||||||
|
@ -591,7 +591,7 @@ pub static INSTRUCTION_SET: [Option<Instruction>; 256] = [
|
||||||
/* 4B */ Option::None,
|
/* 4B */ Option::None,
|
||||||
/* 4C */ instr!(jmp, abs, 3),
|
/* 4C */ instr!(jmp, abs, 3),
|
||||||
/* 4D */ instr!(eor, abs, 4),
|
/* 4D */ instr!(eor, abs, 4),
|
||||||
/* 4E */ Option::None,
|
/* 4E */ instr!(lsr, abs, 6),
|
||||||
/* 4F */ Option::None,
|
/* 4F */ Option::None,
|
||||||
|
|
||||||
/* 50 */ instr!(bvc, rel, 2),
|
/* 50 */ instr!(bvc, rel, 2),
|
||||||
|
@ -625,7 +625,7 @@ pub static INSTRUCTION_SET: [Option<Instruction>; 256] = [
|
||||||
/* 6B */ Option::None,
|
/* 6B */ Option::None,
|
||||||
/* 6C */ Option::None,
|
/* 6C */ Option::None,
|
||||||
/* 6D */ instr!(adc, abs, 4),
|
/* 6D */ instr!(adc, abs, 4),
|
||||||
/* 6E */ Option::None,
|
/* 6E */ instr!(ror, abs, 6),
|
||||||
/* 6F */ Option::None,
|
/* 6F */ Option::None,
|
||||||
|
|
||||||
/* 70 */ instr!(bvs, rel, 2),
|
/* 70 */ instr!(bvs, rel, 2),
|
||||||
|
@ -697,7 +697,7 @@ pub static INSTRUCTION_SET: [Option<Instruction>; 256] = [
|
||||||
/* AF */ Option::None,
|
/* AF */ Option::None,
|
||||||
|
|
||||||
/* B0 */ instr!(bcs, rel, 2),
|
/* B0 */ instr!(bcs, rel, 2),
|
||||||
/* B1 */ Option::None,
|
/* B1 */ instr!(lda, idy, 5),
|
||||||
/* B2 */ Option::None,
|
/* B2 */ Option::None,
|
||||||
/* B3 */ Option::None,
|
/* B3 */ Option::None,
|
||||||
/* B4 */ Option::None,
|
/* B4 */ Option::None,
|
||||||
|
@ -725,9 +725,9 @@ pub static INSTRUCTION_SET: [Option<Instruction>; 256] = [
|
||||||
/* C9 */ instr!(cmp, imm, 2),
|
/* C9 */ instr!(cmp, imm, 2),
|
||||||
/* CA */ instr!(dex, imp, 2),
|
/* CA */ instr!(dex, imp, 2),
|
||||||
/* CB */ Option::None,
|
/* CB */ Option::None,
|
||||||
/* CC */ Option::None,
|
/* CC */ instr!(cpy, abs, 4),
|
||||||
/* CD */ Option::None,
|
/* CD */ instr!(cmp, abs, 4),
|
||||||
/* CE */ Option::None,
|
/* CE */ instr!(dec, abs, 6),
|
||||||
/* CF */ Option::None,
|
/* CF */ Option::None,
|
||||||
|
|
||||||
/* D0 */ instr!(bne, rel, 2),
|
/* D0 */ instr!(bne, rel, 2),
|
||||||
|
@ -759,9 +759,9 @@ pub static INSTRUCTION_SET: [Option<Instruction>; 256] = [
|
||||||
/* E9 */ instr!(sbc, imm, 2),
|
/* E9 */ instr!(sbc, imm, 2),
|
||||||
/* EA */ instr!(nop, imp, 2),
|
/* EA */ instr!(nop, imp, 2),
|
||||||
/* EB */ Option::None,
|
/* EB */ Option::None,
|
||||||
/* EC */ Option::None,
|
/* EC */ instr!(cpx, abs, 4),
|
||||||
/* ED */ Option::None,
|
/* ED */ instr!(sbc, abs, 4),
|
||||||
/* EE */ Option::None,
|
/* EE */ instr!(inc, abs, 6),
|
||||||
/* EF */ Option::None,
|
/* EF */ Option::None,
|
||||||
|
|
||||||
/* F0 */ instr!(beq, rel, 2),
|
/* F0 */ instr!(beq, rel, 2),
|
||||||
|
|
Loading…
Reference in a new issue