forked from Lea/invadeez
16-bit increment and decrement
This commit is contained in:
parent
c35340ecce
commit
d186950e99
|
@ -68,3 +68,15 @@ pub fn dcr(register: Register, state: &mut EmulatorState) {
|
|||
set_cc(state, result as u16, 0b1101);
|
||||
set_register(register, result, state);
|
||||
}
|
||||
|
||||
/// Increase register pair
|
||||
pub fn inx(register: Register, state: &mut EmulatorState) {
|
||||
let (result, _) = get_register_pair(register, state).overflowing_add(1);
|
||||
set_register_pair(register, result, state);
|
||||
}
|
||||
|
||||
/// Decrease register pair
|
||||
pub fn dcx(register: Register, state: &mut EmulatorState) {
|
||||
let (result, _) = get_register_pair(register, state).overflowing_sub(1);
|
||||
set_register_pair(register, result, state);
|
||||
}
|
||||
|
|
|
@ -62,10 +62,10 @@ fn tick(state: &mut EmulatorState) {
|
|||
0xfb => state.ei = true, // EI
|
||||
0xf3 => state.ei = false, // DI
|
||||
0x76 => {
|
||||
// HLT
|
||||
if state.ei {
|
||||
todo!()
|
||||
} else {
|
||||
// HLT
|
||||
println!("HLT called after DI; exiting.");
|
||||
print_state(state);
|
||||
std::process::exit(0);
|
||||
|
@ -99,6 +99,18 @@ fn tick(state: &mut EmulatorState) {
|
|||
0x29 => arithmetic::dad(Register::H, state),
|
||||
0x39 => arithmetic::dad(Register::SP, state),
|
||||
|
||||
// INX
|
||||
0x03 => arithmetic::inx(Register::B, state),
|
||||
0x13 => arithmetic::inx(Register::D, state),
|
||||
0x23 => arithmetic::inx(Register::H, state),
|
||||
0x33 => arithmetic::inx(Register::SP, state),
|
||||
|
||||
// DCX
|
||||
0x0b => arithmetic::dcx(Register::B, state),
|
||||
0x1b => arithmetic::dcx(Register::D, state),
|
||||
0x2b => arithmetic::dcx(Register::H, state),
|
||||
0x3b => arithmetic::dcx(Register::SP, state),
|
||||
|
||||
0x80..=0x87 => arithmetic::add(register_from_num(instruction & 0xf), state), // ADD
|
||||
0x88..=0x8f => arithmetic::adc(register_from_num(instruction & 0xf), state), // ADC
|
||||
0xc6 => arithmetic::adi(next_byte(), state), // ADI
|
||||
|
|
Loading…
Reference in a new issue