forked from Lea/invadeez
compare instructions
This commit is contained in:
parent
c61c814e55
commit
cb26b0ff77
|
@ -57,6 +57,16 @@ 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);
|
||||
|
|
|
@ -124,9 +124,11 @@ fn tick(state: &mut EmulatorState) {
|
|||
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
|
||||
0xb8..=0xbf => arithmetic::cmp_reg(register_from_num(instruction & 0xf), state), // CMP
|
||||
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),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue