From f1b128baeb5a8ab1ae1683a395b180d4cb113fb4 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 11 Feb 2019 20:46:06 +0100 Subject: [PATCH] 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. --- mach/i80/libem/rst.s | 12 +++++++++++- mach/i80/ncg/table | 18 +++++++++++++++--- mach/i80/top/table | 3 ++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/mach/i80/libem/rst.s b/mach/i80/libem/rst.s index 7bf6ade29..2e13584e5 100644 --- a/mach/i80/libem/rst.s +++ b/mach/i80/libem/rst.s @@ -17,6 +17,11 @@ shld 0x11 lxi h, rst3 shld 0x19 + + lhld rst4 + shld 0x20 + lhld rst4+2 + shld 0x22 ret ! de = [bc+const1] (remember bc is the frame pointer) @@ -69,4 +74,9 @@ rst3: dad b ret - \ No newline at end of file + + ! Adjust flags for signed comparison +rst4: + rpo + xri 0x80 + ret diff --git a/mach/i80/ncg/table b/mach/i80/ncg/table index 00587bcbf..963a1f07f 100644 --- a/mach/i80/ncg/table +++ b/mach/i80/ncg/table @@ -13,6 +13,12 @@ EM_WSIZE = 2 EM_PSIZE = 2 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 PROPERTIES @@ -103,7 +109,7 @@ INSTRUCTIONS jnz label:ro cost(3,10). jp 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). lda label:ro kills a cost(3,13). ldax regind:ro kills a cost(1, 7). @@ -1860,6 +1866,7 @@ pat blt sui {const1, %1.num & 0xff} mov a, %2.1 sbi {const1, %1.num >> 8} + SIGN_ADJUST jm {label, $1} with hl_or_de const2 STACK uses areg @@ -1868,14 +1875,16 @@ pat blt sub %1.2 mvi a, {const1, %2.num >> 8} sbb %1.1 + SIGN_ADJUST jm {label, $1} with hl_or_de hl_or_de STACK uses areg gen - mov a,%2.2 + mov a, %2.2 sub %1.2 - mov a,%2.1 + mov a, %2.1 sbb %1.1 + SIGN_ADJUST jm {label,$1} pat bgt @@ -1891,6 +1900,7 @@ pat bge sui {const1, %1.num & 0xff} mov a, %2.1 sbi {const1, %1.num >> 8} + SIGN_ADJUST jp {label, $1} with hl_or_de const2 STACK uses areg @@ -1899,6 +1909,7 @@ pat bge sub %1.2 mvi a, {const1, %2.num >> 8} sbb %1.1 + SIGN_ADJUST jp {label, $1} with hl_or_de hl_or_de STACK uses areg @@ -1907,6 +1918,7 @@ pat bge sub %1.2 mov a,%2.1 sbb %1.1 + SIGN_ADJUST jp {label,$1} pat ble diff --git a/mach/i80/top/table b/mach/i80/top/table index e77100735..9ff98a330 100644 --- a/mach/i80/top/table +++ b/mach/i80/top/table @@ -1,5 +1,5 @@ -/* 68020 desciptor table for ACK target optimizer */ +/* 8080 desciptor table for ACK target optimizer */ MAXOP 2; @@ -14,5 +14,6 @@ xchg : inx h : xchg -> inx d ; xchg : inx d : xchg -> inx h ; cpi 0 -> ora a ; +call X : ret -> jmp X ; %%;