SL=4
+#define WANT_I80_8085
+
STACKHELPERS=128
PROPERTIES
a: areg,reg.
b,c,d,e,h,l: reg.
-bc("b")=b+c: regpair, regind, bcreg, bc_or_de.
de("d")=d+e: regpair, regind, dereg, bc_or_de, hl_or_de.
hl("h")=h+l: regpair, hlreg, hl_or_de.
+bc("b")=b+c: regpair, regind, bcreg, bc_or_de.
sp: stackpointer.
psw=a: psword. /* in fact psw also includes condition codes */
dcr reg:rw:cc cost(1, 5).
dcr m:rw:cc cost(1, 7).
dcx b_d_h_sp:rw cost(1, 5).
+ dsub kills hl cost(1, 10).
/* di cost(1, 4). */
/* ei cost(1, 4). */
/* hlt cost(1, 4). */
inr m:rw:cc cost(1, 7).
inx b_d_h_sp:rw cost(1, 5).
jc label:ro cost(3,10).
+ jk label:ro cost(3,10).
jm label:ro cost(3,10).
jmp label:ro cost(3,10).
jnc label:ro cost(3,10).
+ jnk label:ro cost(3,10).
jnz label:ro cost(3,10).
jp label:ro cost(3,10).
/* jpe label:ro cost(3,10). */
jz label:ro cost(3,10).
lda label:ro kills a cost(3,13).
ldax regind:ro kills a cost(1, 7).
+ ldhl const1:ro cost(2, 10).
+ lhlx cost(1, 10).
lhld label:ro kills hl cost(3,16).
lxi b_d_h_sp:wo,immediate:ro cost(3,10).
mov reg:wo,reg:ro cost(1, 5).
sbb reg1:ro kills a:cc cost(1, 4).
sbi const1:ro kills a:cc cost(2, 7).
shld label:ro cost(3,16).
+ shlx kills hl:cc cost(1, 10).
sphl cost(1, 5).
sta label:ro cost(3,13).
stax regind:ro cost(1, 7).
from fp to hlreg
gen
- lhld {label, ".fp"}
+ rst {const1, 6}
TESTS
uses regpair=%1
yields %a
-from hl_or_de
- uses hl_or_de
- gen
- xchg.
- yields %a
+ from hl_or_de
+ uses hl_or_de
+ gen
+ xchg.
+ yields %a
from regpair
uses regpair=%1
uses regpair=%1
yields %a
+ from smallpconst2
+ uses hlreg
+ gen
+ ldhl {const1, %1.num}
+ yields %a
+
from smallpconst2
uses reg={const1, %1.num & 0xff}
yields %a
gen
lhld %1
yields hl
+#ifdef WANT_I80_8085
+ with dereg
+ uses hlreg
+ gen
+ lhlx.
+ yields %a
+#else
with hlreg
uses regpair
gen
inx %1
mov %a.1, {m}
yields %a
+#endif
pat loi $1==4
with exact label
with label hlreg
gen
shld %1
+#ifdef WANT_I80_8085
+ with hlreg dereg
+ gen
+ shlx.
+#else
with hlreg regpair
gen
mov {m}, %2.2
mov {m}, e
inx %2
mov {m}, d
+#endif
pat sti $1==4
with label hlreg dereg
yields %2 {const2, 0-%1.num}
leaving
adi 2
+#ifdef WANT_I80_8085
+ with hlreg bcreg
+ gen
+ dsub.
+ yields hl
+#else
with regpair const2
uses areg
gen
sbb %1.1
mov %2.1,a
yields %2
+#endif
pat sbi $1==4
kills ALL
jmp {label,$1}
pat blt
+#ifdef WANT_I80_8085
+ with hlreg bcreg STACK
+ gen
+ dsub.
+ jk {label, $1}
+#else
with hlreg dereg STACK
uses areg
gen
Call {label, ".cmps_mag"}
#endif
jc {label, $1}
+#endif
pat bgt
leaving
blt $1
pat bge
+ with hlreg bcreg STACK
+#ifdef WANT_I80_8085
+ gen
+ dsub.
+ jnk {label, $1}
+#else
with hlreg dereg STACK
uses areg
gen
Call {label, ".cmps_mag"}
#endif
jnc {label, $1}
+#endif
pat ble
leaving