mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-04 14:35:41 +00:00
gr-sim: fix carry flag in SBC
This commit is contained in:
parent
ecc4a5bb1c
commit
3b7529991e
@ -68,9 +68,11 @@ void sbc(int value) {
|
||||
int temp_value;
|
||||
|
||||
temp_a=a&0xff;
|
||||
temp_value=value&0xff;
|
||||
temp_value=(~value)&0xff;
|
||||
|
||||
result=temp_a-temp_value-(!c);
|
||||
result=temp_a+temp_value+c;
|
||||
|
||||
// printf("SBC: %x - %x (%x) = %x\n",a,value,c,result);
|
||||
|
||||
c=(result&0x100)>>8;
|
||||
n=(result&0x80)>>7;
|
||||
@ -79,6 +81,8 @@ void sbc(int value) {
|
||||
|
||||
a=result&0xff;
|
||||
z=(a==0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void cmp(int value) {
|
||||
|
@ -54,7 +54,7 @@ static void test_sbc(void) {
|
||||
if (a!=((i-j-0)&0xff)) {
|
||||
printf("SBC: Error! %d-%d should be %d, not %d\n",i,j,i-j-0,a);
|
||||
}
|
||||
if (c!=(((i-j-0)>>8)&0x1)) {
|
||||
if (c==(((i-j-0)>>8)&0x1)) {
|
||||
printf("SBC: Error! Carry should be %d, not %d\n",((i-j-0)>>8)&0x1,c);
|
||||
}
|
||||
if ((a==0) && (z!=1)) printf("SBC error, zflag wrong\n");
|
||||
@ -71,7 +71,7 @@ static void test_sbc(void) {
|
||||
if (a!=((i-j-1)&0xff)) {
|
||||
printf("SBC: Error! %d-%d should be %d, not %d\n",i,j,i-j-1,a);
|
||||
}
|
||||
if (c!=(((i-j-1)>>8)&0x1)) {
|
||||
if (c==(((i-j-1)>>8)&0x1)) {
|
||||
printf("SBC: Error! Carry should be %d, not %d\n",((i-j-1)>>8)&0x1,c);
|
||||
}
|
||||
if ((a==0) && (z!=1)) printf("SBC error, zflag wrong\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user