Signed comparisons now work correctly; sadly, Star Trek increases from 39656 to

39726 bytes. Note that the emulator doesn't set P/V correctly and all the tests
fail. Testing in z80ex works fine.
This commit is contained in:
David Given 2019-02-11 20:46:06 +01:00
parent 34e9573929
commit f1b128baeb
3 changed files with 28 additions and 5 deletions

View file

@ -17,6 +17,11 @@
shld 0x11 shld 0x11
lxi h, rst3 lxi h, rst3
shld 0x19 shld 0x19
lhld rst4
shld 0x20
lhld rst4+2
shld 0x22
ret ret
! de = [bc+const1] (remember bc is the frame pointer) ! de = [bc+const1] (remember bc is the frame pointer)
@ -69,4 +74,9 @@ rst3:
dad b dad b
ret ret
! Adjust flags for signed comparison
rst4:
rpo
xri 0x80
ret

View file

@ -13,6 +13,12 @@ EM_WSIZE = 2
EM_PSIZE = 2 EM_PSIZE = 2
EM_BSIZE = 4 EM_BSIZE = 4
#ifdef USE_I80_RSTS
#define SIGN_ADJUST rst {const1, 4}
#else
#define SIGN_ADJUST jpo {label, 1f} xri {const1, 0x80} 1:
#endif
SL=4 SL=4
PROPERTIES PROPERTIES
@ -103,7 +109,7 @@ INSTRUCTIONS
jnz label:ro cost(3,10). jnz label:ro cost(3,10).
jp label:ro cost(3,10). jp label:ro cost(3,10).
/* jpe label:ro cost(3,10). */ /* jpe label:ro cost(3,10). */
/* jpo label:ro cost(3,10). */ jpo label:ro cost(3,10).
jz label:ro cost(3,10). jz label:ro cost(3,10).
lda label:ro kills a cost(3,13). lda label:ro kills a cost(3,13).
ldax regind:ro kills a cost(1, 7). ldax regind:ro kills a cost(1, 7).
@ -1860,6 +1866,7 @@ pat blt
sui {const1, %1.num & 0xff} sui {const1, %1.num & 0xff}
mov a, %2.1 mov a, %2.1
sbi {const1, %1.num >> 8} sbi {const1, %1.num >> 8}
SIGN_ADJUST
jm {label, $1} jm {label, $1}
with hl_or_de const2 STACK with hl_or_de const2 STACK
uses areg uses areg
@ -1868,14 +1875,16 @@ pat blt
sub %1.2 sub %1.2
mvi a, {const1, %2.num >> 8} mvi a, {const1, %2.num >> 8}
sbb %1.1 sbb %1.1
SIGN_ADJUST
jm {label, $1} jm {label, $1}
with hl_or_de hl_or_de STACK with hl_or_de hl_or_de STACK
uses areg uses areg
gen gen
mov a,%2.2 mov a, %2.2
sub %1.2 sub %1.2
mov a,%2.1 mov a, %2.1
sbb %1.1 sbb %1.1
SIGN_ADJUST
jm {label,$1} jm {label,$1}
pat bgt pat bgt
@ -1891,6 +1900,7 @@ pat bge
sui {const1, %1.num & 0xff} sui {const1, %1.num & 0xff}
mov a, %2.1 mov a, %2.1
sbi {const1, %1.num >> 8} sbi {const1, %1.num >> 8}
SIGN_ADJUST
jp {label, $1} jp {label, $1}
with hl_or_de const2 STACK with hl_or_de const2 STACK
uses areg uses areg
@ -1899,6 +1909,7 @@ pat bge
sub %1.2 sub %1.2
mvi a, {const1, %2.num >> 8} mvi a, {const1, %2.num >> 8}
sbb %1.1 sbb %1.1
SIGN_ADJUST
jp {label, $1} jp {label, $1}
with hl_or_de hl_or_de STACK with hl_or_de hl_or_de STACK
uses areg uses areg
@ -1907,6 +1918,7 @@ pat bge
sub %1.2 sub %1.2
mov a,%2.1 mov a,%2.1
sbb %1.1 sbb %1.1
SIGN_ADJUST
jp {label,$1} jp {label,$1}
pat ble pat ble

View file

@ -1,5 +1,5 @@
/* 68020 desciptor table for ACK target optimizer */ /* 8080 desciptor table for ACK target optimizer */
MAXOP 2; MAXOP 2;
@ -14,5 +14,6 @@ xchg : inx h : xchg -> inx d ;
xchg : inx d : xchg -> inx h ; xchg : inx d : xchg -> inx h ;
cpi 0 -> ora a ; cpi 0 -> ora a ;
call X : ret -> jmp X ;
%%; %%;