-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp.rs
More file actions
27 lines (24 loc) · 785 Bytes
/
php.rs
File metadata and controls
27 lines (24 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use crate::{cpu::CPU, ins::Instruction, mem::Addr};
use crate::Byte;
/// Push Processor Status - Pushes a copy of the status flags on to the stack.
pub struct PHP(pub Addr);
impl Instruction for PHP {
fn execute(&self, cpu: &mut CPU) {
match self {
PHP(Addr::Implicit) => {
cpu.write_byte(CPU::stack_address(cpu.sp), cpu.flags.to_owned().into());
// Decrease stack pointer (PUSH)
cpu.sp -= 1;
// Increase program counter
cpu.pc += 1;
},
_ => panic!("Operation not supported!")
}
}
fn code(&self) -> Byte {
match self {
PHP(Addr::Implicit) => 0x48,
_ => panic!("Operation not supported!")
}
}
}