forked from Lea/invadeez
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);
|
set_cc(state, result);
|
||||||
state.a = (result & 0xff) as u8;
|
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 std::{fs, env};
|
||||||
use instructions::arithmetic::add;
|
use instructions::arithmetic;
|
||||||
|
|
||||||
mod instructions;
|
mod instructions;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ pub struct ConditionCodes {
|
||||||
ac: bool,
|
ac: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
pub enum Register {
|
pub enum Register {
|
||||||
B, C, D, E,
|
B, C, D, E,
|
||||||
H, L, M, A,
|
H, L, M, A,
|
||||||
|
@ -120,9 +121,10 @@ fn tick(state: &mut EmulatorState) {
|
||||||
};
|
};
|
||||||
|
|
||||||
match instruction {
|
match instruction {
|
||||||
0x0 => {} // NOP
|
0x00 => {} // NOP
|
||||||
0x80..=0x87 => add(register_from_num(instruction & 0xf), state), // ADD
|
0x80..=0x87 => arithmetic::add(register_from_num(instruction & 0xf), state), // ADD
|
||||||
_ => not_implemented(state),
|
0xc6 => arithmetic::adi(next_byte(), state), // ADI
|
||||||
|
_ => not_implemented(state),
|
||||||
}
|
}
|
||||||
|
|
||||||
state.pc += 1;
|
state.pc += 1;
|
||||||
|
|
Loading…
Reference in a new issue