1
0
mirror of https://github.com/mre/mos6502.git synced 2024-06-01 14:41:38 +00:00
This commit is contained in:
omarandlorraine 2024-04-28 01:50:11 +02:00 committed by GitHub
commit 978b0bfdf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -788,8 +788,7 @@ impl<M: Bus, V: Variant> CPU<M, V> {
|| (a_after == 0 && c_before == 0x01)
|| (value == 0xff && c_before == 0x01);
let did_overflow = (a_before > 127 && value > 127 && a_after < 128)
|| (a_before < 128 && value < 128 && a_after > 127);
let did_overflow = (a_after ^ a_before) & (a_after ^ value) & 0x80 != 0;
let mask = Status::PS_CARRY | Status::PS_OVERFLOW;
@ -820,8 +819,7 @@ impl<M: Bus, V: Variant> CPU<M, V> {
|| (a_after == 0 && c_before == 0x01)
|| (value == 0xff && c_before == 0x01);
let did_overflow = (a_before > 127 && value > 127 && a_after < 128)
|| (a_before < 128 && value < 128 && a_after > 127);
let did_overflow = (a_after ^ a_before) & (a_after ^ value) & 0x80 != 0;
let mask = Status::PS_CARRY | Status::PS_OVERFLOW;
@ -854,18 +852,7 @@ impl<M: Bus, V: Variant> CPU<M, V> {
let a_after = a_before.wrapping_sub(value).wrapping_sub(nc);
// The overflow flag is set on two's-complement overflow.
//
// range of A is -128 to 127
// range of - M - (1 - C) is -128 to 128
// -(127 + 1) to -(-128 + 0)
//
let over = (nc == 0 && value > 127) && a_before < 128 && a_after > 127;
let under =
(a_before > 127) && (0u8.wrapping_sub(value).wrapping_sub(nc) > 127) && a_after < 128;
let did_overflow = over || under;
let did_overflow = (a_after ^ a_before) & (a_after ^ value) & 0x80 == 0;
let mask = Status::PS_CARRY | Status::PS_OVERFLOW;
@ -896,18 +883,7 @@ impl<M: Bus, V: Variant> CPU<M, V> {
let a_after = a_before.wrapping_sub(value).wrapping_sub(nc);
// The overflow flag is set on two's-complement overflow.
//
// range of A is -128 to 127
// range of - M - (1 - C) is -128 to 128
// -(127 + 1) to -(-128 + 0)
//
let over = (nc == 0 && value > 127) && a_before < 128 && a_after > 127;
let under =
(a_before > 127) && (0u8.wrapping_sub(value).wrapping_sub(nc) > 127) && a_after < 128;
let did_overflow = over || under;
let did_overflow = (a_after ^ a_before) & (a_after ^ value) & 0x80 == 0;
let mask = Status::PS_CARRY | Status::PS_OVERFLOW;