mirror of
https://github.com/mre/mos6502.git
synced 2025-01-04 22:31:52 +00:00
Fix the PHP opcode (#92)
* unit test for php * get test passing --------- Co-authored-by: Sam M W <you@example.com>
This commit is contained in:
parent
6ce85db45c
commit
b52e47bbb5
12
src/cpu.rs
12
src/cpu.rs
@ -427,7 +427,7 @@ impl<M: Bus> CPU<M> {
|
|||||||
}
|
}
|
||||||
(Instruction::PHP, OpInput::UseImplied) => {
|
(Instruction::PHP, OpInput::UseImplied) => {
|
||||||
// Push status
|
// Push status
|
||||||
let val = self.registers.status.bits();
|
let val = self.registers.status.bits() | 0x30;
|
||||||
self.push_on_stack(val);
|
self.push_on_stack(val);
|
||||||
}
|
}
|
||||||
(Instruction::PLA, OpInput::UseImplied) => {
|
(Instruction::PLA, OpInput::UseImplied) => {
|
||||||
@ -1153,6 +1153,16 @@ mod tests {
|
|||||||
assert!(cpu.registers.status.contains(Status::PS_CARRY));
|
assert!(cpu.registers.status.contains(Status::PS_CARRY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn php_sets_bits_4_and_5() {
|
||||||
|
let mut cpu = CPU::new(Ram::new());
|
||||||
|
cpu.execute_instruction((Instruction::PHP, OpInput::UseImplied));
|
||||||
|
cpu.execute_instruction((Instruction::PLA, OpInput::UseImplied));
|
||||||
|
cpu.execute_instruction((Instruction::AND, OpInput::UseImmediate(0x30)));
|
||||||
|
|
||||||
|
assert_eq!(cpu.registers.accumulator, 0x30);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn and_test() {
|
fn and_test() {
|
||||||
let mut cpu = CPU::new(Ram::new());
|
let mut cpu = CPU::new(Ram::new());
|
||||||
|
Loading…
Reference in New Issue
Block a user