mfw overflowing_add
This commit is contained in:
parent
5be0da1a90
commit
1398de8181
|
@ -48,8 +48,8 @@ pub fn dad(register: Register, state: &mut EmulatorState) {
|
|||
_ => panic!("Cannot perform DAD on register {:?}", register),
|
||||
};
|
||||
|
||||
let result = num as u32 + u16::from_le_bytes([state.l, state.h]) as u32;
|
||||
state.cc.c = result > 0xffff;
|
||||
let (result, overflow) = num.overflowing_add(u16::from_le_bytes([state.l, state.h]));
|
||||
state.cc.c = overflow;
|
||||
state.h = (result >> 8) as u8;
|
||||
state.l = result as u8;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue