-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplp.rs
More file actions
29 lines (26 loc) · 963 Bytes
/
plp.rs
File metadata and controls
29 lines (26 loc) · 963 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
28
29
use crate::{cpu::CPU, ins::Instruction, mem::Addr};
use crate::Byte;
/// Pull Processor Status - Pulls an 8 bit value from the stack and into the processor
/// flags. The flags will take on new states as determined by the value pulled.
pub struct PLP(pub Addr);
impl Instruction for PLP {
fn execute(&self, cpu: &mut CPU) {
match self {
PLP(Addr::Implicit) => {
// Read the value from the top of the stack and transform it into `StatusFlags`
cpu.flags = cpu.read_byte(CPU::stack_address(cpu.sp + 1)).into();
// Increment stack pointer (POP)
cpu.sp += 1;
// Increment program counter
cpu.pc += 1;
},
_ => panic!("Operation not supported!")
}
}
fn code(&self) -> Byte {
match self {
PLP(Addr::Implicit) => 0x28,
_ => panic!("Operation not supported!")
}
}
}