forked from Lea/invadeez
Compare commits
No commits in common. "08a15a2e51956c72cd8395f22d348818720ab301" and "c61c814e552694c156b5ca41c2bc8a125450a824" have entirely different histories.
08a15a2e51
...
c61c814e55
|
@ -57,16 +57,6 @@ bitwise_op!(and, and_reg, &);
|
|||
bitwise_op!(or, or_reg, |);
|
||||
bitwise_op!(xor, xor_reg, ^);
|
||||
|
||||
pub fn cmp_reg(register: Register, state: &mut EmulatorState) {
|
||||
cmp(get_register(register, state), state);
|
||||
}
|
||||
|
||||
pub fn cmp(byte: u8, state: &mut EmulatorState) {
|
||||
let (result, carry) = state.a.overflowing_sub(byte);
|
||||
state.cc.c = carry;
|
||||
set_cc(state, result);
|
||||
}
|
||||
|
||||
/// Double precision add - Add B&C, D&E or H&L to H&L
|
||||
pub fn dad(register: Register, state: &mut EmulatorState) {
|
||||
let num = get_register_pair(register, state);
|
||||
|
|
|
@ -111,29 +111,22 @@ fn tick(state: &mut EmulatorState) {
|
|||
0x2b => arithmetic::dcx(Register::H, state),
|
||||
0x3b => arithmetic::dcx(Register::SP, state),
|
||||
|
||||
0x27 => panic!("Auxiliary Carry not implemented, unable to execute DAA instruction"),
|
||||
0x2f => state.a = !state.a, // CMA
|
||||
0x37 => state.cc.c = true, // STC
|
||||
0x3f => state.cc.c = !state.cc.c, // CMC
|
||||
|
||||
0x80..=0x87 => arithmetic::add_reg(register_from_num(instruction & 0x7), false, state), // ADD
|
||||
0x88..=0x8f => arithmetic::add_reg(register_from_num(instruction & 0x7), state.cc.c, state), // ADC
|
||||
0x80..=0x87 => arithmetic::add_reg(register_from_num(instruction & 0xf), false, state), // ADD
|
||||
0x88..=0x8f => arithmetic::add_reg(register_from_num(instruction & 0xf), state.cc.c, state), // ADC
|
||||
0xc6 => arithmetic::add(next_byte(), false, state), // ADI
|
||||
0xce => arithmetic::add(next_byte(), state.cc.c, state), // ACI
|
||||
|
||||
0x90..=0x97 => arithmetic::sub_reg(register_from_num(instruction & 0x7), false, state), // SUB
|
||||
0x98..=0x9f => arithmetic::sub_reg(register_from_num(instruction & 0x7), state.cc.c, state), // SBB
|
||||
0x90..=0x97 => arithmetic::sub_reg(register_from_num(instruction & 0xf), false, state), // SUB
|
||||
0x98..=0x9f => arithmetic::sub_reg(register_from_num(instruction & 0xf), state.cc.c, state), // SBB
|
||||
0xd6 => arithmetic::sub(next_byte(), false, state), // SUI
|
||||
0xde => arithmetic::sub(next_byte(), state.cc.c, state), // SBI
|
||||
|
||||
0xa0..=0xa7 => arithmetic::and_reg(register_from_num(instruction & 0x7), state), // ANA
|
||||
0xa8..=0xaf => arithmetic::xor_reg(register_from_num(instruction & 0x7), state), // XRA
|
||||
0xb0..=0xb7 => arithmetic::or_reg(register_from_num(instruction & 0x7), state), // ORA
|
||||
0xb8..=0xbf => arithmetic::cmp_reg(register_from_num(instruction & 0x7), state), // CMP
|
||||
0xa0..=0xa7 => arithmetic::and_reg(register_from_num(instruction & 0xf), state), // ANA
|
||||
0xa8..=0xaf => arithmetic::xor_reg(register_from_num(instruction & 0xf), state), // XRA
|
||||
0xb0..=0xb7 => arithmetic::or_reg(register_from_num(instruction & 0xf), state), // ORA
|
||||
0xe6 => arithmetic::and(next_byte(), state), // ANI
|
||||
0xee => arithmetic::xor(next_byte(), state), // XRI
|
||||
0xf6 => arithmetic::or(next_byte(), state), // ORI
|
||||
0xfe => arithmetic::cmp(next_byte(), state), // CPI
|
||||
|
||||
_ => not_implemented(state),
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ pub enum Register {
|
|||
}
|
||||
|
||||
/// Returns a Register enum based on the input number 0..7 in the order B,C,D,E,H,L,M,A
|
||||
#[track_caller]
|
||||
pub fn register_from_num(b: u8) -> Register {
|
||||
match b {
|
||||
0 => Register::B,
|
||||
|
|
Loading…
Reference in a new issue