chore(cpu): move RST behaviour to a method
This commit is contained in:
@@ -1092,10 +1092,10 @@ impl Instruction {
|
||||
}
|
||||
Instruction::RST(n) => {
|
||||
// RST n | Push current address onto the stack, jump to 0x0000 + n
|
||||
let addr = cpu.register_pair(RegisterPair::PC);
|
||||
Self::push(cpu, addr);
|
||||
cpu.set_register_pair(RegisterPair::PC, n as u16);
|
||||
Cycle::new(16)
|
||||
|
||||
// The same behaviour will occur when handling an interrupt so this code
|
||||
// is relegated to a method
|
||||
Self::reset(cpu, n)
|
||||
}
|
||||
Instruction::RLC(reg) => {
|
||||
// RLC r[z] | Rotate register r[z] left
|
||||
@@ -1614,6 +1614,13 @@ impl Instruction {
|
||||
|
||||
(lower << 4) | upper
|
||||
}
|
||||
|
||||
pub fn reset(cpu: &mut Cpu, vector: u8) -> Cycle {
|
||||
let addr = cpu.register_pair(RegisterPair::PC);
|
||||
Self::push(cpu, addr);
|
||||
cpu.set_register_pair(RegisterPair::PC, vector as u16);
|
||||
Cycle::new(16)
|
||||
}
|
||||
}
|
||||
|
||||
impl Instruction {
|
||||
|
Reference in New Issue
Block a user