implement ADI
This commit is contained in:
parent
a867c30f16
commit
06447c917a
|
@ -13,3 +13,9 @@ pub fn add(register: Register, state: &mut EmulatorState) {
|
|||
set_cc(state, result);
|
||||
state.a = (result & 0xff) as u8;
|
||||
}
|
||||
|
||||
pub fn adi(byte: u8, state: &mut EmulatorState) {
|
||||
let result = state.a as u16 + byte as u16;
|
||||
set_cc(state, result);
|
||||
state.a = result as u8;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use std::{fs, env};
|
||||
use instructions::arithmetic::add;
|
||||
use instructions::arithmetic;
|
||||
|
||||
mod instructions;
|
||||
|
||||
|
@ -34,6 +34,7 @@ pub struct ConditionCodes {
|
|||
ac: bool,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum Register {
|
||||
B, C, D, E,
|
||||
H, L, M, A,
|
||||
|
@ -120,8 +121,9 @@ fn tick(state: &mut EmulatorState) {
|
|||
};
|
||||
|
||||
match instruction {
|
||||
0x0 => {} // NOP
|
||||
0x80..=0x87 => add(register_from_num(instruction & 0xf), state), // ADD
|
||||
0x00 => {} // NOP
|
||||
0x80..=0x87 => arithmetic::add(register_from_num(instruction & 0xf), state), // ADD
|
||||
0xc6 => arithmetic::adi(next_byte(), state), // ADI
|
||||
_ => not_implemented(state),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue