Implement ADD16

This commit is contained in:
John 2024-07-09 01:05:40 -05:00
parent a6066d1fdf
commit fad95d5046

View File

@ -470,9 +470,13 @@ mod instructions {
Ok(()) Ok(())
} }
pub fn add16(&mut self, reg: R16) -> IResult { pub fn add16(&mut self, reg: R16) -> IResult {
let hl = self.hl.wide().0.to_le_bytes(); let (value, h) = (self[reg], self[R8::H].0);
let addn = self[reg].0.to_le_bytes(); let value_h = (value.0 >> 8) as u8;
eprintln!("Add {hl:?} to {addn:?} and store the half- and full-carry flags"); let hc = half_carry_add(value_h, h);
let carry = h.overflowing_add(value_h).1;
self.set_n(false).set_h(hc).set_c(carry);
*self.hl.wide_mut() += value;
Ok(()) Ok(())
} }
#[allow(unused)] #[allow(unused)]