Fix nearly all the comparisons, a lot of which were broken. Using a rst for

unsigned comparisons is surprisingly not that useful due to marshalling
overhead; it's only four bytes to do inline (plus jc), or six for a constant.
Also add some useful top optimisations.  Star Trek goes from 39890 to 39450
bytes.
This commit is contained in:
David Given 2019-02-15 21:30:27 +01:00
parent 91c75f81b5
commit d63a359a49
5 changed files with 70 additions and 7 deletions

View file

@ -15,4 +15,5 @@
xra h
jp .cmpu_mag ! signs are the same, so an unsigned comparison will do
xra h ! set A=H and set the sign flag
ral ! move sign flag into carry
ret

View file

@ -15,5 +15,4 @@
sub l
mov a, d
sbb h
rar
ret

View file

@ -14,7 +14,6 @@
!
! Also:
! 48 call .cmps_mag
! 25 call .cmpu_mag
.define .rst_init
.rst_init:
@ -28,8 +27,6 @@
lxi h, .fstoren2
call copy
lxi h, .cmps_mag
call copy
lxi h, .cmpu_mag
jmp copy
! Copies eight bytes from HL to DE.
@ -39,7 +36,7 @@ copy:
mov a, m
stax d
inx h
inx d
inr e
dcr c
jnz .1
ret

View file

@ -1618,6 +1618,70 @@ leaving cal ".cmf4" asp 8 lfr 2
pat cmf $1==8
leaving cal ".cmf8" asp 16 lfr 2
pat cmu zlt $1==2
with regpair regpair STACK
uses areg
gen
mov a, %2.2
sub %1.2
mov a, %2.1
sbb %1.1
jc {label, $2}
with const2 regpair STACK
uses areg
gen
mov a, %2.2
sbi {const1, %1.num & 0xff}
mov a, %2.1
sbi {const1, %1.num >> 8}
jc {label, $2}
with regpair const2 STACK
uses areg
gen
mvi a, {const1, %2.num & 0xff}
sub %1.2
mvi a, {const1, %2.num >> 8}
sbb %1.1
jc {label, $2}
pat cmu zgt $1==2
leaving
exg 2
cmu 2
zlt $2
pat cmu zge $1==2
with regpair regpair STACK
uses areg
gen
mov a, %2.2
sub %1.2
mov a, %2.1
sbb %1.1
jnc {label, $2}
with const2 regpair STACK
uses areg
gen
mov a, %2.2
sbi {const1, %1.num & 0xff}
mov a, %2.1
sbi {const1, %1.num >> 8}
jnc {label, $2}
with regpair const2 STACK
uses areg
gen
mvi a, {const1, %2.num & 0xff}
sub %1.2
mvi a, {const1, %2.num >> 8}
sbb %1.1
jnc {label, $2}
pat cmu zle $1==2
leaving
exg 2
cmu 2
zge $2
pat cmu $1==2
with hl_or_de hl_or_de
uses areg
@ -1883,7 +1947,7 @@ pat blt
#else
Call {label, ".cmps_mag"}
#endif
jm {label, $1}
jc {label, $1}
pat bgt
leaving
@ -1899,7 +1963,7 @@ pat bge
#else
Call {label, ".cmps_mag"}
#endif
jp {label, $1}
jnc {label, $1}
pat ble
leaving

View file

@ -19,4 +19,6 @@ call X : ret -> jmp X ;
push h : lxi h, X : pop d -> lxi d, X : xchg ;
push d : lxi d, X : pop h -> lxi h, X : xchg ;
push h : lhld h, X : pop d -> xchg : lhld X ;
%%;