-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtxs.rs
More file actions
27 lines (24 loc) · 741 Bytes
/
txs.rs
File metadata and controls
27 lines (24 loc) · 741 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;
/// Transfer X to Stack Pointer - Copies the current contents of the X register into the
/// stack pointer.
pub struct TXS(pub Addr);
impl Instruction for TXS {
fn execute(&self, cpu: &mut CPU) {
match self {
// 1B, 2C
TXS(Addr::Implicit) => {
cpu.write_byte(CPU::stack_address(cpu.sp), cpu.reg.x);
// Increment program counter
cpu.pc += 1;
},
_ => panic!("Operation not supported!")
}
}
fn code(&self) -> Byte {
match self {
TXS(Addr::Implicit) => 0x9A,
_ => panic!("Operation not supported!")
}
}
}