Improve subtractions, using dad and inline constants where possible. Shrinks

Star Trek from 39740 to 39656 bytes.
This commit is contained in:
David Given 2019-02-10 19:40:48 +01:00
parent 7d34cd7407
commit fca54ccc1b

View file

@ -623,37 +623,68 @@ pat sde
/****************************************/ /****************************************/
pat adi $1==2 pat adi $1==2
with hlreg dereg with hlreg dereg
gen dad de yields hl gen
with dereg hlreg dad de
gen dad de yields hl yields hl
with hlreg hlreg with dereg hlreg
gen dad hl yields hl gen
with dereg dereg dad de
gen xchg. yields hl
dad hl yields hl with hlreg hlreg
gen
dad hl
yields hl
with dereg dereg
gen
xchg.
dad hl
yields hl
pat adi $1==4 pat adi $1==4
kills ALL kills ALL
gen Call {label,".adi4"} gen
Call {label,".adi4"}
pat sbi $1==2 pat sbi $1==2
with hl_or_de hl_or_de with const2 hl_or_de
uses areg yields %2 {const2, 0-%1.num}
gen mov a,%2.2 leaving
adi 2
with smallconst2 hl_or_de
yields %2 {smallconst2, 0-%1.num}
leaving
adi 2
with hl_or_de const2
uses areg
gen
mvi a, {const1, %2.num & 0xff}
sub %1.2
mov %1.2, a
mvi a, {const1, %2.num >> 8}
sbb %1.1
mov %1.1, a
yields %1
with hl_or_de hl_or_de
uses areg
gen
mov a,%2.2
sub %1.2 sub %1.2
mov %1.2,a mov %1.2,a
mov a,%2.1 mov a,%2.1
sbb %1.1 sbb %1.1
mov %1.1,a yields %1 mov %1.1,a
with hl_or_de hl_or_de yields %1
uses areg with hl_or_de hl_or_de
gen mov a,%2.2 uses areg
gen
mov a,%2.2
sub %1.2 sub %1.2
mov %2.2,a mov %2.2,a
mov a,%2.1 mov a,%2.1
sbb %1.1 sbb %1.1
mov %2.1,a yields %2 mov %2.1,a
yields %2
pat sbi $1==4 pat sbi $1==4
kills ALL kills ALL