Skip to content

Commit

Permalink
emu: Add TXS, TSX
Browse files Browse the repository at this point in the history
  • Loading branch information
Granddave committed Dec 30, 2023
1 parent 50d7cc5 commit 0ca0deb
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/emulator/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,20 @@ impl Cpu {
return 2;
}
// TSX
(ASTMnemonic::TSX, _, ASTOperand::Implied) => {
self.load_register(Register::X, self.sp);
return 2;
}
// TXA
(ASTMnemonic::TXA, _, ASTOperand::Implied) => {
self.load_register(Register::A, self.x);
return 2;
}
// TXS
(ASTMnemonic::TXS, _, ASTOperand::Implied) => {
self.sp = self.x;
return 2;
}
// TYA
(ASTMnemonic::TYA, _, ASTOperand::Implied) => {
self.load_register(Register::A, self.y);
Expand Down Expand Up @@ -2326,6 +2334,38 @@ mod tests {
expected_cycles: 2 + 2,
..Default::default()
},
// TSX
TestCase {
code: "TSX",
expected_cpu: Cpu {
x: 0xff,
sp: 0xff,
pc: PROGRAM_START + 1,
status: Status {
negative: true,
..Default::default()
},
..Default::default()
},
expected_cycles: 2,
..Default::default()
},
// TXS
TestCase {
code: "LDX #$fc\nTXS",
expected_cpu: Cpu {
x: 0xfc,
sp: 0xfc,
pc: PROGRAM_START + 2 + 1,
status: Status {
negative: true,
..Default::default()
},
..Default::default()
},
expected_cycles: 2 + 2,
..Default::default()
},
]
.into_iter()
.for_each(|tc| tc.run_test());
Expand Down

0 comments on commit 0ca0deb

Please sign in to comment.