mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-12-25 09:29:48 +00:00
More canonical test for oVerflow
This commit is contained in:
parent
59d151d684
commit
41b8ca7700
@ -188,8 +188,8 @@ static void logic_ADC(/*uint8_t*/int _a, /*uint8_t*/int _b, uint8_t *result, uin
|
|||||||
|
|
||||||
int8_t a = (int8_t)_a;
|
int8_t a = (int8_t)_a;
|
||||||
int8_t b = (int8_t)_b;
|
int8_t b = (int8_t)_b;
|
||||||
bool is_neg = (a < 0);
|
bool signA = a>>7;
|
||||||
bool is_negb = (b < 0);
|
bool signB = b>>7;
|
||||||
|
|
||||||
int8_t carry = (*flags & fC) ? 1 : 0;
|
int8_t carry = (*flags & fC) ? 1 : 0;
|
||||||
*flags &= ~fC;
|
*flags &= ~fC;
|
||||||
@ -208,13 +208,9 @@ static void logic_ADC(/*uint8_t*/int _a, /*uint8_t*/int _b, uint8_t *result, uin
|
|||||||
*flags |= fC;
|
*flags |= fC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_neg && is_negb ) {
|
if (signA == signB) {
|
||||||
if (a < res) {
|
uint8_t signResult = (res&0xff)>>7;
|
||||||
*flags |= fV;
|
if (signA != signResult) {
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( !is_neg && !is_negb ) {
|
|
||||||
if (a > res) {
|
|
||||||
*flags |= fV;
|
*flags |= fV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5773,8 +5769,8 @@ static void logic_SBC(/*uint8_t*/int _a, /*uint8_t*/int _b, uint8_t *result, uin
|
|||||||
|
|
||||||
int8_t a = (int8_t)_a;
|
int8_t a = (int8_t)_a;
|
||||||
int8_t b = (int8_t)_b;
|
int8_t b = (int8_t)_b;
|
||||||
bool is_neg = (a < 0);
|
bool signA = a>>7;
|
||||||
bool is_negb = (b < 0);
|
bool signB = b>>7;
|
||||||
|
|
||||||
int8_t borrow = ((*flags & fC) == 0x0) ? 1 : 0;
|
int8_t borrow = ((*flags & fC) == 0x0) ? 1 : 0;
|
||||||
*flags |= fC;
|
*flags |= fC;
|
||||||
@ -5792,13 +5788,9 @@ static void logic_SBC(/*uint8_t*/int _a, /*uint8_t*/int _b, uint8_t *result, uin
|
|||||||
*flags &= ~fC;
|
*flags &= ~fC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !is_neg && is_negb ) {
|
if (signA != signB) {
|
||||||
if (a > res) {
|
uint8_t signResult = (res&0xff)>>7;
|
||||||
*flags |= fV;
|
if (signA != signResult) {
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( is_neg && !is_negb ) {
|
|
||||||
if (a < res) {
|
|
||||||
*flags |= fV;
|
*flags |= fV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user