From 360e1525ae80c98ac7c1c76cbd24d254e0774352 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 12 Feb 2019 11:57:37 +0100 Subject: [PATCH] Replace the non-working Z80 style signed comparison sign adjustment with something which actually works on the 8080. Sadly, Star Trek is up to 40243 bytes again. --- mach/i80/libem/rst.s | 12 +--------- mach/i80/ncg/table | 56 +++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/mach/i80/libem/rst.s b/mach/i80/libem/rst.s index 2e13584e5..a5234bd67 100644 --- a/mach/i80/libem/rst.s +++ b/mach/i80/libem/rst.s @@ -17,11 +17,6 @@ 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) @@ -74,9 +69,4 @@ rst3: dad b ret - - ! Adjust flags for signed comparison -rst4: - rpo - xri 0x80 - ret + diff --git a/mach/i80/ncg/table b/mach/i80/ncg/table index 963a1f07f..1af10558a 100644 --- a/mach/i80/ncg/table +++ b/mach/i80/ncg/table @@ -13,12 +13,6 @@ 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 @@ -1862,30 +1856,39 @@ pat blt with const2 hl_or_de STACK uses areg gen + mov a, %2.1 + xri {const1, 0x80} + mov %2.1, a mov a, %2.2 sui {const1, %1.num & 0xff} mov a, %2.1 - sbi {const1, %1.num >> 8} - SIGN_ADJUST - jm {label, $1} + sbi {const1, (%1.num >> 8) ^ 0x80} + jc {label, $1} with hl_or_de const2 STACK uses areg gen + mov a, %1.1 + xri {const1, 0x80} + mov %1.1, a mvi a, {const1, %2.num & 0xff} sub %1.2 - mvi a, {const1, %2.num >> 8} + mvi a, {const1, (%2.num >> 8) ^ 0x80} sbb %1.1 - SIGN_ADJUST - jm {label, $1} + jc {label, $1} with hl_or_de hl_or_de STACK uses areg gen + mov a, %2.1 + xri {const1, 0x80} + mov %2.1, a + mov a, %1.1 + xri {const1, 0x80} + mov %1.1, a mov a, %2.2 sub %1.2 mov a, %2.1 sbb %1.1 - SIGN_ADJUST - jm {label,$1} + jc {label,$1} pat bgt leaving @@ -1896,30 +1899,39 @@ pat bge with const2 hl_or_de STACK uses areg gen + mov a, %2.1 + xri {const1, 0x80} + mov %2.1, a mov a, %2.2 sui {const1, %1.num & 0xff} mov a, %2.1 - sbi {const1, %1.num >> 8} - SIGN_ADJUST - jp {label, $1} + sbi {const1, (%1.num >> 8) ^ 0x80} + jnc {label, $1} with hl_or_de const2 STACK uses areg gen + mov a, %1.1 + xri {const1, 0x80} + mov %1.1, a mvi a, {const1, %2.num & 0xff} sub %1.2 - mvi a, {const1, %2.num >> 8} + mvi a, {const1, (%2.num >> 8) ^ 0x80} sbb %1.1 - SIGN_ADJUST - jp {label, $1} + jnc {label, $1} with hl_or_de hl_or_de STACK uses areg gen + mov a, %2.1 + xri {const1, 0x80} + mov %2.1, a + mov a, %1.1 + xri {const1, 0x80} + mov %1.1, a mov a,%2.2 sub %1.2 mov a,%2.1 sbb %1.1 - SIGN_ADJUST - jp {label,$1} + jnc {label,$1} pat ble leaving