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
sub %1.2 adi 2
mov %1.2,a with smallconst2 hl_or_de
mov a,%2.1 yields %2 {smallconst2, 0-%1.num}
sbb %1.1 leaving
mov %1.1,a yields %1 adi 2
with hl_or_de hl_or_de with hl_or_de const2
uses areg uses areg
gen mov a,%2.2 gen
sub %1.2 mvi a, {const1, %2.num & 0xff}
mov %2.2,a sub %1.2
mov a,%2.1 mov %1.2, a
sbb %1.1 mvi a, {const1, %2.num >> 8}
mov %2.1,a yields %2 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
mov %1.2,a
mov a,%2.1
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
mov %2.2,a
mov a,%2.1
sbb %1.1
mov %2.1,a
yields %2
pat sbi $1==4 pat sbi $1==4
kills ALL kills ALL