Use nicely optimised helper tools to do signed comparisons of words. Star Trek
goes from 40452 to 39890 bytes.
This commit is contained in:
parent
0694cf34b0
commit
2924ce8ffa
18
mach/i80/libem/cmps_mag.s
Normal file
18
mach/i80/libem/cmps_mag.s
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
.sect .text
|
||||||
|
.sect .rom
|
||||||
|
.sect .data
|
||||||
|
.sect .bss
|
||||||
|
.sect .text
|
||||||
|
|
||||||
|
! Does a tristate signed comparison of hl <> de.
|
||||||
|
! Returns m flag if hl < de.
|
||||||
|
! Returns p flag if hl >= de.
|
||||||
|
! This doesn't set z coherently.
|
||||||
|
|
||||||
|
.define .cmps_mag
|
||||||
|
.cmps_mag:
|
||||||
|
mov a, d
|
||||||
|
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
|
||||||
|
ret
|
19
mach/i80/libem/cmpu_mag.s
Normal file
19
mach/i80/libem/cmpu_mag.s
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
.sect .text
|
||||||
|
.sect .rom
|
||||||
|
.sect .data
|
||||||
|
.sect .bss
|
||||||
|
.sect .text
|
||||||
|
|
||||||
|
! Does a tristate unsigned comparison of hl <> de.
|
||||||
|
! Returns m flag if hl < de.
|
||||||
|
! Returns p flag if hl >= de.
|
||||||
|
! This doesn't set z coherently.
|
||||||
|
|
||||||
|
.define .cmpu_mag
|
||||||
|
.cmpu_mag:
|
||||||
|
mov a, e
|
||||||
|
sub l
|
||||||
|
mov a, d
|
||||||
|
sbb h
|
||||||
|
rar
|
||||||
|
ret
|
|
@ -1875,42 +1875,11 @@ pat bra
|
||||||
jmp {label,$1}
|
jmp {label,$1}
|
||||||
|
|
||||||
pat blt
|
pat blt
|
||||||
with const2 hl_or_de STACK
|
with hlreg dereg STACK
|
||||||
uses areg
|
uses areg
|
||||||
gen
|
gen
|
||||||
mov a, %2.1
|
Call {label, ".cmps_mag"}
|
||||||
xri {const1, 0x80}
|
jm {label, $1}
|
||||||
mov %2.1, a
|
|
||||||
mov a, %2.2
|
|
||||||
sui {const1, %1.num & 0xff}
|
|
||||||
mov a, %2.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) ^ 0x80}
|
|
||||||
sbb %1.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
|
|
||||||
jc {label,$1}
|
|
||||||
|
|
||||||
pat bgt
|
pat bgt
|
||||||
leaving
|
leaving
|
||||||
|
@ -1918,42 +1887,11 @@ pat bgt
|
||||||
blt $1
|
blt $1
|
||||||
|
|
||||||
pat bge
|
pat bge
|
||||||
with const2 hl_or_de STACK
|
with hlreg dereg STACK
|
||||||
uses areg
|
uses areg
|
||||||
gen
|
gen
|
||||||
mov a, %2.1
|
Call {label, ".cmpu_mag"}
|
||||||
xri {const1, 0x80}
|
jp {label, $1}
|
||||||
mov %2.1, a
|
|
||||||
mov a, %2.2
|
|
||||||
sui {const1, %1.num & 0xff}
|
|
||||||
mov a, %2.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) ^ 0x80}
|
|
||||||
sbb %1.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
|
|
||||||
jnc {label,$1}
|
|
||||||
|
|
||||||
pat ble
|
pat ble
|
||||||
leaving
|
leaving
|
||||||
|
|
Loading…
Reference in a new issue