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

@ -624,36 +624,67 @@ pat sde
pat adi $1==2
with hlreg dereg
gen dad de yields hl
gen
dad de
yields hl
with dereg hlreg
gen dad de yields hl
gen
dad de
yields hl
with hlreg hlreg
gen dad hl yields hl
gen
dad hl
yields hl
with dereg dereg
gen xchg.
dad hl yields hl
gen
xchg.
dad hl
yields hl
pat adi $1==4
kills ALL
gen Call {label,".adi4"}
gen
Call {label,".adi4"}
pat sbi $1==2
with const2 hl_or_de
yields %2 {const2, 0-%1.num}
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
gen
mov a,%2.2
sub %1.2
mov %1.2,a
mov a,%2.1
sbb %1.1
mov %1.1,a yields %1
mov %1.1,a
yields %1
with hl_or_de hl_or_de
uses areg
gen mov a,%2.2
gen
mov a,%2.2
sub %1.2
mov %2.2,a
mov a,%2.1
sbb %1.1
mov %2.1,a yields %2
mov %2.1,a
yields %2
pat sbi $1==4
kills ALL