1985-01-17 14:31:34 +00:00
|
|
|
/************************************************************/
|
|
|
|
/************************************************************/
|
|
|
|
/******* ******/
|
|
|
|
/******* 8 0 8 0 B A C K E N D T A B L E ******/
|
|
|
|
/******* ******/
|
|
|
|
/************************************************************/
|
|
|
|
/************************************************************/
|
|
|
|
|
|
|
|
|
1994-06-24 14:02:31 +00:00
|
|
|
rcsid = "$Id$"
|
1985-03-18 12:55:07 +00:00
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
EM_WSIZE = 2
|
|
|
|
EM_PSIZE = 2
|
|
|
|
EM_BSIZE = 4
|
|
|
|
|
|
|
|
SL=4
|
|
|
|
|
2019-02-13 21:45:22 +00:00
|
|
|
STACKHELPERS=128
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
PROPERTIES
|
|
|
|
|
|
|
|
areg /* the a-register */
|
|
|
|
lbreg /* the registers used as localbase */
|
|
|
|
reg /* the free registers */
|
|
|
|
regpair /* register pairs bc, de and hl */
|
|
|
|
regind /* register indirect */
|
|
|
|
dereg /* de-register-pair */
|
|
|
|
hlreg /* hl-register-pair */
|
1985-03-04 13:42:38 +00:00
|
|
|
hl_or_de /* de- or hl-register-pair */
|
1985-01-17 14:31:34 +00:00
|
|
|
localbase
|
|
|
|
stackpointer
|
1985-03-04 13:42:38 +00:00
|
|
|
psword
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
REGISTERS
|
|
|
|
|
|
|
|
a :areg,reg.
|
|
|
|
b,c :lbreg.
|
|
|
|
d,e,h,l :reg.
|
|
|
|
lb("b")=b+c :regpair, localbase, regind.
|
1985-03-04 13:42:38 +00:00
|
|
|
de("d")=d+e :regpair, regind, dereg, hl_or_de.
|
|
|
|
hl("h")=h+l :regpair, hlreg, hl_or_de.
|
1985-01-17 14:31:34 +00:00
|
|
|
sp :stackpointer.
|
1985-03-04 13:42:38 +00:00
|
|
|
psw=a :psword. /* in fact psw also includes
|
|
|
|
condition codes */
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
TOKENS
|
|
|
|
|
1985-03-04 13:42:38 +00:00
|
|
|
const1 = { INT num; } 1 num.
|
|
|
|
const2 = { INT num; } 2 num.
|
2019-03-08 22:06:34 +00:00
|
|
|
largeconst2 = { INT num; } 2 num. /* Word-sized constant with low byte zero */
|
2019-02-13 19:56:10 +00:00
|
|
|
smallpconst2 = { INT num; } 2 num. /* Byte-sized positive constant */
|
|
|
|
smallnconst2 = { INT num; } 2 num. /* Byte-sized negative constant */
|
1985-03-04 13:42:38 +00:00
|
|
|
label = { ADDR off; } 2 off.
|
2019-02-13 21:45:22 +00:00
|
|
|
plabel = { ADDR off; INT param; } 2 off param.
|
1985-03-04 13:42:38 +00:00
|
|
|
m = { } 2 cost(0,3) "m".
|
2019-02-13 23:05:08 +00:00
|
|
|
comment = { ADDR str; } 2 "! " str.
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
SETS
|
|
|
|
|
1985-03-04 13:42:38 +00:00
|
|
|
reg1 = reg + lbreg + m.
|
|
|
|
b_d_h_sp = regpair + stackpointer.
|
|
|
|
b_d_h_psw = regpair + psword.
|
2019-03-08 22:06:34 +00:00
|
|
|
immediate = largeconst2 + smallpconst2 + smallnconst2 + const2 + label.
|
1985-03-04 13:42:38 +00:00
|
|
|
src1 = reg.
|
|
|
|
src2 = hl_or_de + const2 + label.
|
|
|
|
src1or2 = src1 + src2.
|
2019-03-08 22:06:34 +00:00
|
|
|
anyreg = reg + regpair.
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
INSTRUCTIONS
|
|
|
|
|
1985-03-04 13:42:38 +00:00
|
|
|
/* aci const1:ro kills a:cc cost(2, 7). */
|
|
|
|
adc reg1:ro kills a:cc cost(1, 4).
|
|
|
|
add reg1:ro kills a:cc cost(1, 4).
|
2019-03-08 22:06:34 +00:00
|
|
|
adi const1:ro kills a:cc cost(2, 7).
|
1985-03-04 13:42:38 +00:00
|
|
|
ana reg1:ro kills a:cc cost(1, 4).
|
|
|
|
ani const1:ro kills a:cc cost(2, 7).
|
|
|
|
Call "call" label:ro cost(3,17).
|
2019-02-13 21:45:22 +00:00
|
|
|
Call "call" plabel:ro cost(3,17).
|
1985-01-17 14:31:34 +00:00
|
|
|
/* 'call' is a reserved word */
|
1985-03-04 13:42:38 +00:00
|
|
|
/* cc label:ro cost(3,14). */
|
|
|
|
/* cm label:ro cost(3,14). */
|
|
|
|
cma kills a cost(3,14).
|
|
|
|
cmc kills:cc cost(1, 4).
|
|
|
|
cmp reg1:ro kills:cc cost(1, 4).
|
|
|
|
/* cnc label:ro cost(3,14). */
|
|
|
|
cnz label:ro cost(3,14).
|
|
|
|
/* cp label:ro cost(3,14). */
|
|
|
|
/* cpe label:ro cost(3,14). */
|
|
|
|
cpi const1:ro kills:cc cost(2, 7).
|
|
|
|
/* cpo label:ro cost(3,14). */
|
|
|
|
/* cz label:ro cost(3,14). */
|
|
|
|
/* daa kills a:cc cost(1, 4). */
|
2019-02-06 23:06:32 +00:00
|
|
|
data1 ".data1" const1:ro.
|
|
|
|
data2 ".data2" const2:ro.
|
1985-03-04 13:42:38 +00:00
|
|
|
dad b_d_h_sp:ro kills hl:cc cost(1,10).
|
|
|
|
dcr reg+lbreg:rw:cc cost(1, 5).
|
|
|
|
dcr m:rw:cc cost(1, 7).
|
|
|
|
dcx b_d_h_sp:rw cost(1, 5).
|
|
|
|
/* di cost(1, 4). */
|
|
|
|
/* ei cost(1, 4). */
|
|
|
|
/* hlt cost(1, 4). */
|
|
|
|
/* in const1:ro cost(2,10). */
|
|
|
|
inr reg+lbreg:rw:cc cost(1, 5).
|
|
|
|
inr m:rw:cc cost(1, 7).
|
|
|
|
inx b_d_h_sp:rw cost(1, 5).
|
|
|
|
jc label:ro cost(3,10).
|
|
|
|
jm label:ro cost(3,10).
|
|
|
|
jmp label:ro cost(3,10).
|
|
|
|
jnc label:ro cost(3,10).
|
|
|
|
jnz label:ro cost(3,10).
|
|
|
|
jp label:ro cost(3,10).
|
|
|
|
/* jpe label:ro cost(3,10). */
|
2019-02-11 19:46:06 +00:00
|
|
|
jpo label:ro cost(3,10).
|
1985-03-04 13:42:38 +00:00
|
|
|
jz label:ro cost(3,10).
|
|
|
|
lda label:ro kills a cost(3,13).
|
|
|
|
ldax regind:ro kills a cost(1, 7).
|
|
|
|
lhld label:ro kills hl cost(3,16).
|
|
|
|
lxi b_d_h_sp:wo,immediate:ro cost(3,10).
|
|
|
|
mov reg+lbreg:wo,reg+lbreg:ro cost(1, 5).
|
|
|
|
mov m:wo,reg1:ro cost(1, 4).
|
|
|
|
mov reg1:wo,m:ro cost(1, 4).
|
|
|
|
mvi reg1:wo,const1:ro cost(2, 7).
|
2019-02-13 23:05:08 +00:00
|
|
|
nop comment:ro cost(1, 3).
|
1985-03-04 13:42:38 +00:00
|
|
|
ora reg1:ro kills a:cc cost(1, 4).
|
2019-02-08 21:38:07 +00:00
|
|
|
ori const1:ro kills a:cc cost(2, 7).
|
1985-03-04 13:42:38 +00:00
|
|
|
/* out const1:ro cost(2,10). */
|
|
|
|
pchl cost(1, 5).
|
|
|
|
pop b_d_h_psw:wo cost(1,10).
|
|
|
|
push b_d_h_psw:ro cost(1,10).
|
|
|
|
ral kills a:cc cost(1, 4).
|
|
|
|
rar kills a:cc cost(1, 4).
|
|
|
|
/* rc cost(1, 8). */
|
|
|
|
ret cost(1,10).
|
|
|
|
rlc kills a:cc cost(1, 4).
|
|
|
|
/* rm cost(1, 8). */
|
|
|
|
/* rnc cost(1, 8). */
|
|
|
|
/* rnz cost(1, 8). */
|
|
|
|
/* rp cost(1, 8). */
|
|
|
|
/* rpe cost(1, 8). */
|
|
|
|
/* rpo cost(1, 8). */
|
|
|
|
rrc kills a:cc cost(1, 4).
|
2019-02-07 07:45:20 +00:00
|
|
|
rst const1:ro cost(1,11).
|
1985-03-04 13:42:38 +00:00
|
|
|
/* rz cost(1, 8). */
|
|
|
|
sbb reg1:ro kills a:cc cost(1, 4).
|
2019-02-10 18:22:43 +00:00
|
|
|
sbi const1:ro kills a:cc cost(2, 7).
|
1985-03-04 13:42:38 +00:00
|
|
|
shld label:ro cost(3,16).
|
|
|
|
sphl cost(1, 5).
|
|
|
|
sta label:ro cost(3,13).
|
|
|
|
stax regind:ro cost(1, 7).
|
|
|
|
/* stc kills:cc cost(1, 4). */
|
|
|
|
sub reg1:ro kills a:cc cost(1, 4).
|
|
|
|
sui const1:ro kills a:cc cost(2, 7).
|
|
|
|
xchg kills de hl cost(1, 4).
|
|
|
|
xra reg1:ro kills a:cc cost(1, 4).
|
2019-02-08 21:38:07 +00:00
|
|
|
xri const1:ro kills a:cc cost(2, 7).
|
1985-03-04 13:42:38 +00:00
|
|
|
xthl kills hl cost(1,18).
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-03-08 22:06:34 +00:00
|
|
|
kill anyreg:rw kills :cc cost(0, 0).
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
MOVES
|
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from reg to reg
|
|
|
|
gen
|
|
|
|
mov %2,%1
|
|
|
|
|
|
|
|
from const1 %num==0 to areg
|
|
|
|
gen
|
|
|
|
xra a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from const1 to reg
|
|
|
|
gen
|
|
|
|
mvi %2,%1
|
1985-03-04 13:42:38 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from immediate to b_d_h_sp
|
|
|
|
gen
|
|
|
|
lxi %2,%1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from const1 to reg
|
|
|
|
gen
|
|
|
|
mvi %2, %1
|
|
|
|
|
|
|
|
from const1 to regpair
|
|
|
|
gen
|
|
|
|
mvi %2.2, %1
|
|
|
|
mvi %2.1, {const1, 0}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from reg to regpair
|
|
|
|
gen
|
|
|
|
mov %2.2, %1
|
|
|
|
mvi %2.1, {const1,0}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from regpair to regpair
|
|
|
|
gen
|
|
|
|
mov %2.1, %1.1
|
|
|
|
mov %2.2, %1.2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
TESTS
|
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
to test areg /* dummy test, never used */
|
|
|
|
gen
|
|
|
|
ora a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
STACKINGRULES
|
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from regpair to STACK
|
|
|
|
gen
|
|
|
|
push %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from immediate + reg to STACK
|
|
|
|
uses hl_or_de
|
|
|
|
gen
|
|
|
|
move %1, %a
|
|
|
|
push %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from immediate + reg to STACK
|
|
|
|
gen
|
|
|
|
push hl
|
|
|
|
move %1, hl
|
|
|
|
xthl.
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
COERCIONS
|
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from STACK
|
|
|
|
uses regpair
|
|
|
|
gen
|
|
|
|
pop %a
|
|
|
|
yields %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from STACK
|
|
|
|
uses hl_or_de
|
|
|
|
gen
|
|
|
|
pop %a
|
|
|
|
yields %a.2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from STACK
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
dcx sp
|
|
|
|
pop psw
|
|
|
|
inx sp
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
from immediate
|
|
|
|
uses regpair=%1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
from hl_or_de
|
|
|
|
uses hl_or_de
|
|
|
|
gen
|
|
|
|
xchg.
|
|
|
|
yields %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from regpair
|
|
|
|
uses regpair=%1
|
|
|
|
yields %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from reg
|
|
|
|
uses reusing %1, hl_or_de
|
|
|
|
gen
|
|
|
|
move %1,%a.2
|
|
|
|
move {const1,0},%a.1
|
|
|
|
yields %a
|
1985-03-04 13:42:38 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from hl_or_de yields %1.2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-03-08 22:06:34 +00:00
|
|
|
from largeconst2
|
|
|
|
yields {const2, %1.num}
|
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from smallpconst2
|
|
|
|
yields {const2, %1.num}
|
1985-03-04 13:42:38 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from smallnconst2
|
|
|
|
yields {const2, %1.num}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from const2
|
|
|
|
uses hl_or_de=%1
|
|
|
|
yields %a
|
2019-02-13 19:56:10 +00:00
|
|
|
|
2019-03-08 22:06:34 +00:00
|
|
|
from largeconst2
|
|
|
|
uses hl_or_de=%1
|
|
|
|
yields %a
|
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from smallpconst2
|
|
|
|
uses reg={const1, %1.num & 0xff}
|
|
|
|
yields %a
|
2019-02-08 21:38:07 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from smallnconst2
|
|
|
|
uses reg={const1, %1.num & 0xff}
|
|
|
|
yields %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-15 21:20:07 +00:00
|
|
|
from smallpconst2 %1.num == 1
|
|
|
|
uses reg={const1, 0}
|
|
|
|
gen
|
|
|
|
inr %a
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
from smallnconst2 %1.num == 0-1
|
|
|
|
uses reg={const1, 0}
|
|
|
|
gen
|
|
|
|
dcr %a
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
from const2
|
|
|
|
uses reg={const1, %1.num & 0xff}
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
from hl_or_de
|
|
|
|
uses reg=%1.2
|
|
|
|
yields %a
|
1985-02-01 12:51:56 +00:00
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
PATTERNS
|
|
|
|
|
|
|
|
/*********************************************/
|
|
|
|
/* Group 1: Load instructions */
|
|
|
|
/*********************************************/
|
|
|
|
|
2019-03-08 22:06:34 +00:00
|
|
|
pat loc ($1 != 0) && (($1 & 0xff) == 0)
|
|
|
|
yields {largeconst2, $1}
|
|
|
|
|
2019-02-13 19:56:10 +00:00
|
|
|
pat loc ufit($1, 8)
|
|
|
|
yields {smallpconst2, $1}
|
|
|
|
|
|
|
|
pat loc sfit($1, 8) && ($1<0)
|
|
|
|
yields {smallnconst2, $1}
|
2019-02-08 21:38:07 +00:00
|
|
|
|
|
|
|
pat loc
|
|
|
|
yields {const2, $1}
|
|
|
|
|
2019-02-09 12:29:41 +00:00
|
|
|
pat ldc
|
|
|
|
yields {const2, highw($1)} {const2, loww($1)}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-06 23:06:32 +00:00
|
|
|
#ifdef USE_I80_RSTS
|
2019-02-13 21:45:22 +00:00
|
|
|
pat lol $1==0-2
|
|
|
|
uses dereg, hlreg
|
2019-02-06 23:06:32 +00:00
|
|
|
gen
|
|
|
|
rst {const1, 1}
|
2019-02-13 21:45:22 +00:00
|
|
|
yields de
|
|
|
|
|
|
|
|
pat lol $1==0-4
|
|
|
|
uses dereg, hlreg
|
|
|
|
gen
|
|
|
|
rst {const1, 2}
|
|
|
|
yields de
|
|
|
|
|
|
|
|
pat lol $1==4
|
|
|
|
uses dereg, hlreg
|
|
|
|
gen
|
|
|
|
rst {const1, 3}
|
2019-02-06 23:06:32 +00:00
|
|
|
yields de
|
|
|
|
#endif
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-13 21:45:22 +00:00
|
|
|
pat lol ($1>0) && ($1<=STACKHELPERS)
|
|
|
|
uses dereg, hlreg
|
|
|
|
gen
|
|
|
|
Call {plabel, ".fload", $1}
|
|
|
|
yields de
|
|
|
|
|
|
|
|
pat lol ($1<0) && ($1>=0-STACKHELPERS)
|
|
|
|
uses dereg, hlreg
|
|
|
|
gen
|
|
|
|
Call {plabel, ".floadn", 0-$1}
|
|
|
|
yields de
|
|
|
|
|
2019-02-07 07:45:20 +00:00
|
|
|
pat lol
|
2019-02-15 22:03:01 +00:00
|
|
|
uses dereg, hlreg={const2, $1}
|
2019-02-13 21:45:22 +00:00
|
|
|
gen
|
|
|
|
dad lb
|
|
|
|
mov e, {m}
|
|
|
|
inx hl
|
|
|
|
mov d, {m}
|
2019-02-15 22:03:01 +00:00
|
|
|
yields de
|
2019-02-07 07:45:20 +00:00
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat loe
|
2019-02-09 12:29:41 +00:00
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
lhld {label,$1}
|
|
|
|
yields hl
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lil
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
lol $1
|
|
|
|
loi 2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lof
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
adp $1
|
|
|
|
loi 2
|
|
|
|
|
2019-02-13 21:45:22 +00:00
|
|
|
pat lal ($1>0) && ($1<=STACKHELPERS)
|
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
Call {plabel, ".faddr", $1}
|
|
|
|
yields hl
|
|
|
|
|
|
|
|
pat lal ($1<0) && ($1>=0-STACKHELPERS)
|
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
Call {plabel, ".faddrn", 0-$1}
|
|
|
|
yields hl
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lal
|
2019-02-09 12:29:41 +00:00
|
|
|
uses hlreg={const2,$1}
|
|
|
|
gen
|
|
|
|
dad lb
|
|
|
|
yields hl
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-09 12:29:41 +00:00
|
|
|
pat lae
|
|
|
|
yields {label,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-09 12:29:41 +00:00
|
|
|
pat lxl $1==0
|
|
|
|
yields lb
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lxl $1==1
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
lxa 0
|
|
|
|
loi 2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
1985-03-04 13:42:38 +00:00
|
|
|
pat lxl $1>1 && $1<256
|
1985-01-17 14:31:34 +00:00
|
|
|
uses dereg, areg={const1,$1}, hlreg
|
|
|
|
gen move lb,de
|
|
|
|
1:
|
|
|
|
lxi hl,{const2,SL}
|
|
|
|
dad de
|
1985-03-04 13:42:38 +00:00
|
|
|
mov e,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov d,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
dcr a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lxa $1==0
|
2019-02-09 12:29:41 +00:00
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
move {const2,SL},hl
|
|
|
|
dad lb
|
|
|
|
yields hl
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lxa $1==1
|
|
|
|
uses dereg, hlreg
|
|
|
|
gen move {const2,SL},hl
|
|
|
|
dad lb
|
1985-03-04 13:42:38 +00:00
|
|
|
mov e,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov d,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
lxi hl,{const2,SL}
|
|
|
|
dad de yields hl
|
|
|
|
|
|
|
|
pat lxa $1>1 && $1<256
|
|
|
|
uses dereg, hlreg, areg={const1,$1}
|
|
|
|
gen move lb,de
|
|
|
|
1:
|
|
|
|
lxi hl,{const2,SL}
|
|
|
|
dad de
|
1985-03-04 13:42:38 +00:00
|
|
|
mov e,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov d,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
dcr a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
lxi hl,{const2,SL}
|
|
|
|
dad de yields hl
|
|
|
|
|
|
|
|
pat loi $1==1
|
1985-02-01 12:51:56 +00:00
|
|
|
with exact label
|
|
|
|
uses areg
|
|
|
|
gen lda %1 yields a
|
|
|
|
with dereg
|
|
|
|
uses areg
|
|
|
|
gen ldax de yields a
|
1985-01-17 14:31:34 +00:00
|
|
|
with hlreg
|
1985-03-18 10:00:30 +00:00
|
|
|
uses reusing %1, reg
|
1985-03-04 13:42:38 +00:00
|
|
|
gen mov %a,{m} yields %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loi $1==2
|
|
|
|
with exact label
|
|
|
|
gen lhld %1 yields hl
|
|
|
|
with hlreg
|
|
|
|
uses dereg
|
1985-03-04 13:42:38 +00:00
|
|
|
gen mov e,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
inx %1
|
1985-03-04 13:42:38 +00:00
|
|
|
mov d,{m} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loi $1==4
|
|
|
|
with exact label
|
|
|
|
gen lhld %1
|
|
|
|
xchg.
|
|
|
|
lhld {label,%1.off+2} yields hl de
|
1985-02-01 12:51:56 +00:00
|
|
|
with exact label
|
|
|
|
gen lhld {label,%1.off+2}
|
|
|
|
xchg.
|
|
|
|
lhld %1 yields de hl
|
1985-01-17 14:31:34 +00:00
|
|
|
with hlreg
|
|
|
|
uses dereg, areg
|
1985-03-04 13:42:38 +00:00
|
|
|
gen mov e,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
inx %1
|
1985-03-04 13:42:38 +00:00
|
|
|
mov d,{m}
|
1985-02-01 12:51:56 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov a,{m}
|
1985-02-01 12:51:56 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov h,{m}
|
1985-02-01 12:51:56 +00:00
|
|
|
mov l,a yields hl de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loi $1<=510
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de STACK
|
|
|
|
uses hl_or_de={const2,$1-1}, areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen dad de
|
|
|
|
mvi a,{const1,$1/2}
|
|
|
|
1:
|
1985-03-04 13:42:38 +00:00
|
|
|
mov d,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
dcx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov e,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
dcx hl
|
|
|
|
push de
|
|
|
|
dcr a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loi $1>=512
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
/* 'uses dereg={const2,$1}' fails to kill de. */
|
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".loi"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat los $1==2
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".loi"}
|
|
|
|
|
|
|
|
pat ldl
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
lal $1
|
|
|
|
loi 4
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lde
|
|
|
|
with STACK
|
|
|
|
gen lhld {label,$1+2}
|
|
|
|
push hl
|
|
|
|
lhld {label,$1} yields hl
|
1985-02-01 12:51:56 +00:00
|
|
|
with
|
|
|
|
uses dereg, hlreg
|
|
|
|
gen lhld {label,$1}
|
|
|
|
xchg.
|
|
|
|
lhld {label,$1+2} yields hl de
|
|
|
|
with
|
|
|
|
uses dereg, hlreg
|
|
|
|
gen lhld {label,$1+2}
|
|
|
|
xchg.
|
|
|
|
lhld {label,$1} yields de hl
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ldf
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
adp $1
|
|
|
|
loi 4
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lpi
|
1985-03-04 13:42:38 +00:00
|
|
|
uses hl_or_de={label,$1} yields %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/* Group 2: Store instructions */
|
|
|
|
/******************************************/
|
|
|
|
|
|
|
|
pat stl lol $1==$2
|
|
|
|
with dereg yields de de leaving stl $1
|
|
|
|
|
2019-02-07 08:31:38 +00:00
|
|
|
#ifdef USE_I80_RSTS
|
2019-02-13 21:45:22 +00:00
|
|
|
pat stl $1==0-2
|
|
|
|
with dereg
|
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
rst {const1, 4}
|
2019-02-07 08:31:38 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-13 21:45:22 +00:00
|
|
|
pat stl ($1>0) && ($1<=STACKHELPERS)
|
|
|
|
with dereg
|
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
Call {plabel, ".fstore", $1}
|
|
|
|
|
|
|
|
pat stl ($1<0) && ($1>=0-STACKHELPERS)
|
|
|
|
with dereg
|
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
Call {plabel, ".fstoren", 0-$1}
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat stl
|
2019-02-07 08:31:38 +00:00
|
|
|
with dereg
|
2019-02-13 21:45:22 +00:00
|
|
|
uses hlreg={const2, $1}
|
|
|
|
gen
|
|
|
|
dad lb
|
|
|
|
mov {m}, e
|
|
|
|
inx hl
|
|
|
|
mov {m}, d
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ste loe $1==$2
|
|
|
|
with hlreg yields hl hl leaving ste $1
|
|
|
|
|
|
|
|
pat ste
|
|
|
|
with hlreg
|
|
|
|
gen shld {label,$1}
|
|
|
|
|
|
|
|
pat sil
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
lol $1
|
|
|
|
sti 2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
1985-01-22 19:55:11 +00:00
|
|
|
pat sil lil $1==$2
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
dup 2
|
|
|
|
lol $1
|
|
|
|
sti 2
|
1985-01-22 19:55:11 +00:00
|
|
|
|
|
|
|
pat lil inc sil $1==$3
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
lol $1
|
|
|
|
dup 2
|
|
|
|
loi 2
|
|
|
|
inc 2
|
|
|
|
exg 2
|
|
|
|
sti 2
|
1985-01-22 19:55:11 +00:00
|
|
|
|
2019-02-09 12:29:41 +00:00
|
|
|
pat lil inc sil $1==$3
|
|
|
|
leaving
|
|
|
|
lol $1
|
|
|
|
dup 2
|
|
|
|
loi 2
|
|
|
|
dec 2
|
|
|
|
exg 2
|
|
|
|
sti 2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat stf
|
2019-02-09 12:29:41 +00:00
|
|
|
with hl_or_de STACK
|
|
|
|
uses hl_or_de={const2,$1}
|
|
|
|
gen
|
|
|
|
dad de
|
|
|
|
pop de
|
|
|
|
mov {m},e
|
|
|
|
inx hl
|
|
|
|
mov {m},d
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sti $1==1
|
2019-02-15 21:20:07 +00:00
|
|
|
with label areg
|
|
|
|
gen
|
|
|
|
sta %1
|
|
|
|
with dereg areg
|
|
|
|
gen
|
|
|
|
stax %1
|
|
|
|
with hlreg reg
|
|
|
|
gen
|
|
|
|
mov {m}, %2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sti $1==2
|
2019-02-09 12:29:41 +00:00
|
|
|
with label hlreg
|
|
|
|
gen
|
|
|
|
shld %1
|
|
|
|
with hlreg dereg
|
|
|
|
gen
|
|
|
|
mov {m},e
|
|
|
|
inx %1
|
|
|
|
mov {m},d
|
|
|
|
with dereg hlreg
|
|
|
|
gen
|
|
|
|
xchg.
|
|
|
|
mov {m},e
|
|
|
|
inx %2
|
|
|
|
mov {m},d
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sti $1==4
|
1985-03-04 13:42:38 +00:00
|
|
|
with label hlreg dereg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen shld %1
|
|
|
|
xchg.
|
|
|
|
shld {label,%1.off+2}
|
1985-03-04 13:42:38 +00:00
|
|
|
with label dereg hlreg
|
|
|
|
gen shld {label,%1.off+2}
|
|
|
|
xchg.
|
|
|
|
shld %1
|
1987-11-10 13:49:04 +00:00
|
|
|
with hlreg dereg
|
|
|
|
kills ALL
|
1985-03-04 13:42:38 +00:00
|
|
|
gen mov {m},e
|
1985-02-01 12:51:56 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov {m},d
|
1985-02-01 12:51:56 +00:00
|
|
|
inx hl
|
|
|
|
pop de
|
1985-03-04 13:42:38 +00:00
|
|
|
mov {m},e
|
1985-02-01 12:51:56 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov {m},d
|
1985-01-17 14:31:34 +00:00
|
|
|
|
1985-03-04 13:42:38 +00:00
|
|
|
pat sti $1<512
|
1987-11-10 13:49:04 +00:00
|
|
|
with hlreg
|
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg={const1,$1/2}, dereg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen 1:
|
|
|
|
pop de
|
1985-03-04 13:42:38 +00:00
|
|
|
mov {m},e
|
1985-02-01 12:51:56 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov {m},d
|
1985-02-01 12:51:56 +00:00
|
|
|
inx hl
|
1985-01-17 14:31:34 +00:00
|
|
|
dcr a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sti
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".sti"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sts $1==2
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".sti"}
|
|
|
|
|
|
|
|
pat sdl
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
lal $1
|
|
|
|
sti 4
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sdf
|
2019-02-09 12:29:41 +00:00
|
|
|
leaving
|
|
|
|
adp $1
|
|
|
|
sti 4
|
|
|
|
|
|
|
|
pat sde
|
|
|
|
with hlreg
|
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
shld {label,$1}
|
|
|
|
pop hl
|
|
|
|
shld {label,$1+2}
|
|
|
|
with hlreg dereg
|
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
shld {label,$1}
|
|
|
|
xchg.
|
|
|
|
shld {label,$1+2}
|
|
|
|
with dereg hlreg
|
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
shld {label,$1+2}
|
|
|
|
xchg.
|
|
|
|
shld {label,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
/****************************************/
|
|
|
|
/* Group 3: Integer arithmetic */
|
|
|
|
/****************************************/
|
|
|
|
|
|
|
|
pat adi $1==2
|
2019-03-08 22:06:34 +00:00
|
|
|
with hl_or_de largeconst2
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.1
|
|
|
|
adi {const1, %2.num >> 8}
|
|
|
|
mov %1.1, a
|
|
|
|
kill a
|
|
|
|
yields %1
|
|
|
|
with largeconst2 hl_or_de
|
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
adi 2
|
2019-02-10 18:40:48 +00:00
|
|
|
with hlreg dereg
|
|
|
|
gen
|
|
|
|
dad de
|
|
|
|
yields hl
|
|
|
|
with dereg hlreg
|
|
|
|
gen
|
|
|
|
dad de
|
|
|
|
yields hl
|
|
|
|
with hlreg hlreg
|
|
|
|
gen
|
|
|
|
dad hl
|
|
|
|
yields hl
|
|
|
|
with dereg dereg
|
|
|
|
gen
|
|
|
|
xchg.
|
|
|
|
dad hl
|
|
|
|
yields hl
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat adi $1==4
|
2019-02-10 18:40:48 +00:00
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
Call {label,".adi4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sbi $1==2
|
2019-02-10 18:40:48 +00:00
|
|
|
with const2 hl_or_de
|
|
|
|
yields %2 {const2, 0-%1.num}
|
|
|
|
leaving
|
|
|
|
adi 2
|
2019-03-08 22:06:34 +00:00
|
|
|
with largeconst2 hl_or_de
|
|
|
|
yields %2 {largeconst2, 0-%1.num}
|
|
|
|
leaving
|
|
|
|
adi 2
|
|
|
|
with smallpconst2 hl_or_de
|
|
|
|
yields %2 {smallnconst2, 0-%1.num}
|
|
|
|
leaving
|
|
|
|
adi 2
|
2019-02-13 19:56:10 +00:00
|
|
|
with smallnconst2 hl_or_de
|
|
|
|
yields %2 {smallpconst2, 0-%1.num}
|
2019-02-10 18:40:48 +00:00
|
|
|
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
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-10 18:40:48 +00:00
|
|
|
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
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-10 18:40:48 +00:00
|
|
|
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
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-10 18:40:48 +00:00
|
|
|
yields %2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sbi $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".sbi4"}
|
|
|
|
|
|
|
|
pat mli $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".mli2"} yields de
|
|
|
|
|
|
|
|
pat mli $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".mli4"}
|
|
|
|
|
|
|
|
pat dvi $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
/* 'uses areg={const1,129}' fails to kill a. */
|
|
|
|
gen mvi a,{const1,129}
|
|
|
|
Call {label,".dvi2"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat dvi $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,129}
|
|
|
|
Call {label,".dvi4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat rmi $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,128}
|
|
|
|
Call {label,".dvi2"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat rmi $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,128}
|
|
|
|
Call {label,".dvi4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ngi $1==2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
uses areg
|
|
|
|
gen xra a
|
|
|
|
sub %1.2
|
|
|
|
mov %1.2,a
|
|
|
|
mvi a,{const1,0}
|
|
|
|
sbb %1.1
|
2007-04-29 23:00:31 +00:00
|
|
|
mov %1.1,a yields %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ngi $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".ngi4"}
|
|
|
|
|
2019-02-10 17:44:47 +00:00
|
|
|
pat loc sli ($1==1) && ($2==2)
|
|
|
|
with hlreg
|
|
|
|
gen
|
|
|
|
dad hl
|
|
|
|
yields hl
|
|
|
|
|
|
|
|
pat loc sli ($1>=2) && ($1<=7) && ($2==2)
|
|
|
|
with hlreg
|
|
|
|
gen
|
|
|
|
dad hl
|
|
|
|
yields hl
|
|
|
|
leaving
|
|
|
|
loc $1-1
|
|
|
|
sli 2
|
|
|
|
|
|
|
|
pat loc sli ($1==8) && ($2==2)
|
|
|
|
with hl_or_de
|
|
|
|
gen
|
|
|
|
mov %1.1, %1.2
|
|
|
|
mvi %1.2, {const1, 0}
|
|
|
|
yields %1
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat sli $1==2
|
2019-02-10 17:44:47 +00:00
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
Call {label,".sli2"}
|
|
|
|
yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sli $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".sli4"}
|
|
|
|
|
|
|
|
pat sri $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,1}
|
|
|
|
Call {label,".sri2"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sri $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,1}
|
|
|
|
Call {label,".sri4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
/********************************************/
|
|
|
|
/* Group 4: Unsigned arithmetic */
|
|
|
|
/********************************************/
|
|
|
|
|
|
|
|
pat adu leaving adi $1
|
|
|
|
|
|
|
|
pat sbu leaving sbi $1
|
|
|
|
|
1985-02-01 12:51:56 +00:00
|
|
|
pat mlu $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
gen Call {label,".mlu2"} yields de
|
|
|
|
|
|
|
|
pat mlu $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
gen Call {label,".mli4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat dvu $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,1}
|
|
|
|
Call {label,".dvi2"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat dvu $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,1}
|
|
|
|
Call {label,".dvi4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat rmu $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,0}
|
|
|
|
Call {label,".dvi2"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat rmu $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,0}
|
|
|
|
Call {label,".dvi4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-10 17:44:47 +00:00
|
|
|
pat loc slu ($2==2)
|
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
sli $2
|
|
|
|
|
|
|
|
pat slu
|
|
|
|
leaving
|
|
|
|
sli $1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2007-04-29 23:00:31 +00:00
|
|
|
pat loc sru ($1 == 8) && ($2 == 2)
|
|
|
|
with hl_or_de
|
|
|
|
gen move %1.1, %1.2
|
|
|
|
mvi %1.1, {const1,0} yields %1
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat sru $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,0}
|
|
|
|
Call {label,".sri2"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat sru $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,0}
|
|
|
|
Call {label,".sri4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
1985-03-04 13:42:38 +00:00
|
|
|
|
|
|
|
/********************************************/
|
1985-03-18 10:00:30 +00:00
|
|
|
/* Group 5: Floating point arithmetic */
|
1985-03-04 13:42:38 +00:00
|
|
|
/********************************************/
|
|
|
|
|
2018-04-25 20:09:56 +00:00
|
|
|
pat adf $1==4 leaving cal ".adf4" asp 4
|
|
|
|
pat adf $1==8 leaving cal ".adf8" asp 8
|
|
|
|
pat sbf $1==4 leaving cal ".sbf4" asp 4
|
|
|
|
pat sbf $1==8 leaving cal ".sbf8" asp 8
|
|
|
|
pat mlf $1==4 leaving cal ".mlf4" asp 4
|
|
|
|
pat mlf $1==8 leaving cal ".mlf8" asp 8
|
|
|
|
pat dvf $1==4 leaving cal ".dvf4" asp 4
|
|
|
|
pat dvf $1==8 leaving cal ".dvf8" asp 8
|
|
|
|
pat ngf $1==4 leaving cal ".ngf4"
|
|
|
|
pat ngf $1==8 leaving cal ".ngf8"
|
1985-04-12 14:25:59 +00:00
|
|
|
|
|
|
|
pat fif $1==4
|
2018-04-25 20:09:56 +00:00
|
|
|
leaving lor 1 cal ".fif4" asp 2
|
1985-04-12 14:25:59 +00:00
|
|
|
|
|
|
|
pat fif $1==8
|
2018-04-25 20:09:56 +00:00
|
|
|
leaving lor 1 cal ".fif8" asp 2
|
1985-04-12 14:25:59 +00:00
|
|
|
|
|
|
|
pat fef $1==4
|
2018-04-25 20:09:56 +00:00
|
|
|
leaving lor 1 adp 0-2 cal ".fef4"
|
1985-04-12 14:25:59 +00:00
|
|
|
|
|
|
|
pat fef $1==8
|
2018-04-25 20:09:56 +00:00
|
|
|
leaving lor 1 adp 0-2 cal ".fef8"
|
1985-03-04 13:42:38 +00:00
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
/********************************************/
|
|
|
|
/* Group 6: Pointer arithmetic */
|
|
|
|
/********************************************/
|
|
|
|
|
|
|
|
pat adp $1==0 /* do nothing */
|
|
|
|
|
|
|
|
pat adp $1==1
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen inx %1 yields %1
|
|
|
|
|
|
|
|
pat adp $1==2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen inx %1
|
|
|
|
inx %1 yields %1
|
|
|
|
|
|
|
|
pat adp $1==0-1
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen dcx %1 yields %1
|
|
|
|
|
|
|
|
pat adp $1==0-2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen dcx %1
|
|
|
|
dcx %1 yields %1
|
|
|
|
|
|
|
|
pat adp
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
|
|
|
uses hl_or_de={const2,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
gen dad de yields hl
|
|
|
|
|
|
|
|
pat ads $1==2 leaving adi 2
|
|
|
|
|
|
|
|
pat sbs $1==2 leaving sbi 2
|
|
|
|
|
|
|
|
/********************************************/
|
|
|
|
/* Group 7: Increment/ decrement/ zero */
|
|
|
|
/********************************************/
|
|
|
|
|
|
|
|
pat inc
|
2019-02-09 12:29:41 +00:00
|
|
|
with hl_or_de
|
|
|
|
gen
|
|
|
|
inx %1
|
|
|
|
yields %1
|
|
|
|
|
2019-02-14 22:21:47 +00:00
|
|
|
pat inl ($1>0) && ($1<=STACKHELPERS)
|
2019-02-13 21:45:22 +00:00
|
|
|
uses hlreg
|
2019-02-09 12:29:41 +00:00
|
|
|
gen
|
2019-02-13 21:45:22 +00:00
|
|
|
Call {plabel, ".faddr", $1}
|
2019-02-09 12:29:41 +00:00
|
|
|
inr {m}
|
2019-02-13 21:45:22 +00:00
|
|
|
jnz {label,1f}
|
|
|
|
inx hl
|
|
|
|
inr {m}
|
|
|
|
1:
|
|
|
|
|
2019-02-14 22:21:47 +00:00
|
|
|
pat inl ($1<0) && ($1>=0-STACKHELPERS)
|
2019-02-13 21:45:22 +00:00
|
|
|
uses hlreg
|
|
|
|
gen
|
2019-02-14 22:21:47 +00:00
|
|
|
Call {plabel, ".faddrn", 0-$1}
|
2019-02-13 21:45:22 +00:00
|
|
|
inr {m}
|
|
|
|
jnz {label,1f}
|
2019-02-09 12:29:41 +00:00
|
|
|
inx hl
|
|
|
|
inr {m}
|
|
|
|
1:
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat inl
|
2019-02-09 12:29:41 +00:00
|
|
|
uses hlreg={const2,$1}
|
|
|
|
gen
|
|
|
|
dad lb
|
|
|
|
inr {m}
|
|
|
|
jnz {label,1f}
|
|
|
|
inx hl
|
|
|
|
inr {m}
|
|
|
|
1:
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ine
|
|
|
|
uses hlreg={label,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
gen inr {m}
|
|
|
|
jnz {label,1f}
|
1985-01-17 14:31:34 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
inr {m}
|
1985-01-17 14:31:34 +00:00
|
|
|
1:
|
|
|
|
|
|
|
|
pat dec
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen dcx %1 yields %1
|
|
|
|
|
2019-02-13 21:45:22 +00:00
|
|
|
pat del
|
|
|
|
uses hlreg={const2,$1}
|
2019-02-09 12:29:41 +00:00
|
|
|
gen
|
2019-02-13 21:45:22 +00:00
|
|
|
dad lb
|
2019-02-09 12:29:41 +00:00
|
|
|
mov e, {m}
|
|
|
|
inx hl
|
|
|
|
mov d, {m}
|
|
|
|
dcx de
|
|
|
|
mov {m}, d
|
|
|
|
dcx hl
|
|
|
|
mov {m}, e
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat dee
|
|
|
|
uses hlreg
|
|
|
|
gen lhld {label,$1}
|
|
|
|
dcx hl
|
|
|
|
shld {label,$1}
|
|
|
|
|
|
|
|
pat zrl
|
2019-02-09 12:29:41 +00:00
|
|
|
uses hlreg={const2,$1}, areg
|
|
|
|
gen
|
|
|
|
dad lb
|
|
|
|
xra a
|
|
|
|
mov {m},a
|
|
|
|
inx hl
|
|
|
|
mov {m},a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat zre
|
|
|
|
uses hlreg={const2,0}
|
|
|
|
gen shld {label,$1}
|
|
|
|
|
2018-04-25 20:09:56 +00:00
|
|
|
pat zrf $1==4 leaving zer 4
|
1985-04-12 14:25:59 +00:00
|
|
|
|
2018-04-25 20:09:56 +00:00
|
|
|
pat zrf $1==8 leaving zer 8
|
1985-03-18 10:00:30 +00:00
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat zer $1==2 yields {const2,0}
|
|
|
|
|
|
|
|
pat zer $1==4 yields {const2,0} {const2,0}
|
|
|
|
|
|
|
|
pat zer $1<511
|
1987-11-10 13:49:04 +00:00
|
|
|
kills ALL
|
1985-03-04 13:42:38 +00:00
|
|
|
uses reg={const1,$1/2}, hl_or_de={const2,0}
|
1985-01-17 14:31:34 +00:00
|
|
|
gen 1:
|
|
|
|
push %b
|
|
|
|
dcr %a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat zer
|
1987-11-10 13:49:04 +00:00
|
|
|
kills ALL
|
1985-03-04 13:42:38 +00:00
|
|
|
uses hl_or_de={const2,$1/2}, hl_or_de={const2,0}, areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen xra a
|
|
|
|
1:
|
|
|
|
push %b
|
|
|
|
dcx %a
|
|
|
|
cmp %a.2
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
cmp %a.1
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
/*****************************************/
|
|
|
|
/* Group 8: Convert instructions */
|
|
|
|
/*****************************************/
|
|
|
|
|
|
|
|
pat loc loc cii $1==$2
|
|
|
|
|
|
|
|
pat loc loc cii $1==2 && $2==4
|
2019-02-08 22:16:57 +00:00
|
|
|
with hl_or_de
|
|
|
|
uses hl_or_de, areg
|
|
|
|
gen
|
|
|
|
mov a, %1.1
|
|
|
|
ral.
|
|
|
|
sbb a
|
|
|
|
mov %a.1, a
|
|
|
|
mov %a.2, a
|
|
|
|
yields %a %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc loc cii $1==4 && $2==2
|
2019-02-08 22:16:57 +00:00
|
|
|
with hl_or_de hl_or_de
|
|
|
|
yields %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc loc cii $1==1 && $2==2
|
2019-02-08 22:16:57 +00:00
|
|
|
with reg
|
|
|
|
uses reusing %1, areg=%1, hl_or_de
|
|
|
|
gen
|
|
|
|
mov %b.2, a
|
|
|
|
ral.
|
|
|
|
sbb a
|
|
|
|
mov %b.1, a
|
|
|
|
yields %b
|
|
|
|
with hl_or_de
|
|
|
|
uses areg=%1.2
|
|
|
|
gen
|
|
|
|
ral.
|
|
|
|
sbb a
|
|
|
|
mov %1.1, a
|
|
|
|
yields %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc loc cii $1==1 && $2==4
|
2019-02-08 22:16:57 +00:00
|
|
|
with areg
|
|
|
|
uses hl_or_de, hl_or_de
|
|
|
|
gen
|
|
|
|
mov %b.2, a
|
|
|
|
ral.
|
|
|
|
sbb a
|
|
|
|
mov %b.1, a
|
|
|
|
mov %a.2, a
|
|
|
|
mov %a.1, a
|
|
|
|
yields %a %b
|
|
|
|
with hlreg
|
|
|
|
uses dereg, areg
|
|
|
|
gen
|
|
|
|
mov a, l
|
|
|
|
ral.
|
|
|
|
sbb a
|
|
|
|
mov h, a
|
|
|
|
mov e, a
|
|
|
|
mov d, a
|
|
|
|
yields de hl
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat cii
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,1}
|
|
|
|
Call {label,".cii"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc loc ciu leaving loc $1 loc $2 cuu
|
1985-03-04 13:42:38 +00:00
|
|
|
pat loc loc cui leaving loc $1 loc $2 cuu
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat cui leaving cuu $1
|
|
|
|
|
|
|
|
pat ciu leaving cuu $1
|
|
|
|
|
|
|
|
pat loc loc cuu $1==$2
|
|
|
|
|
|
|
|
pat loc loc cuu $1==2 && $2==4
|
2019-02-17 09:09:22 +00:00
|
|
|
with src1or2
|
|
|
|
yields {const2,0} %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc loc cuu $1==4 && $1==2
|
2019-02-17 09:09:22 +00:00
|
|
|
with src1or2 src1or2
|
|
|
|
yields %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc loc cuu $1==1 && $2==2
|
2019-02-17 09:09:22 +00:00
|
|
|
with reg
|
|
|
|
yields %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc loc cuu $1==1 && $2==4
|
2019-02-17 09:09:22 +00:00
|
|
|
with reg
|
|
|
|
uses reusing %1
|
|
|
|
yields {const2,0} %1
|
|
|
|
with hl_or_de
|
|
|
|
yields {const2,0} %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat cuu
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,0}
|
|
|
|
Call {label,".cii"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2018-04-25 20:09:56 +00:00
|
|
|
pat loc loc cfi $2==2
|
|
|
|
leaving loc $1 loc $2 cal ".cfi" asp 4+$1 loe ".fra"
|
1985-04-12 14:25:59 +00:00
|
|
|
|
2018-04-25 20:09:56 +00:00
|
|
|
pat loc loc cfi $2==4
|
|
|
|
leaving loc $1 loc $2 cal ".cfi" asp 4+$1 lfr 4
|
1985-04-12 14:25:59 +00:00
|
|
|
|
2018-04-25 20:09:56 +00:00
|
|
|
pat loc loc cif $2==4
|
|
|
|
leaving loc $1 cal ".cif4" asp $1-2
|
1985-04-12 14:25:59 +00:00
|
|
|
|
2018-04-25 20:09:56 +00:00
|
|
|
pat loc loc cif $1==2 && $2==8
|
|
|
|
with hl_or_de
|
|
|
|
gen push %1
|
|
|
|
push %1
|
|
|
|
push %1 leaving loc $1 cal ".cif8"
|
1985-04-12 14:25:59 +00:00
|
|
|
|
2018-04-25 20:09:56 +00:00
|
|
|
pat loc loc cif $1==4 && $2==8
|
|
|
|
with hl_or_de hl_or_de
|
|
|
|
gen push %2
|
|
|
|
push %2
|
|
|
|
push %1 leaving loc $1 cal ".cif8"
|
|
|
|
|
|
|
|
pat loc loc cuf $2==4
|
|
|
|
leaving loc $1 cal ".cuf4" asp $1-2
|
|
|
|
|
|
|
|
pat loc loc cuf $1==2 && $2==8
|
|
|
|
with hl_or_de
|
|
|
|
gen push %1
|
|
|
|
push %1
|
|
|
|
push %1 leaving loc $1 cal ".cuf8"
|
|
|
|
|
|
|
|
pat loc loc cuf $1==4 && $2==8
|
|
|
|
with hl_or_de hl_or_de
|
|
|
|
gen push %1
|
|
|
|
push %2
|
|
|
|
push %1 leaving loc $1 cal ".cuf8"
|
|
|
|
|
|
|
|
pat loc loc cff $1==8 && $2==4 leaving cal ".cff4" asp 4
|
|
|
|
|
|
|
|
pat loc loc cff $1==4 && $2==8 leaving dup 4 cal ".cff8"
|
|
|
|
|
|
|
|
pat loc loc cfu $2==2
|
|
|
|
leaving loc $1 loc $2 cal ".cfu" asp 4+$1 loe ".fra"
|
|
|
|
|
|
|
|
pat loc loc cfu $2==4
|
|
|
|
leaving loc $1 loc $2 cal ".cfu" asp 4+$1 lfr 4
|
1985-04-12 14:25:59 +00:00
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
/*****************************************/
|
|
|
|
/* Group 9: Logical instructions */
|
|
|
|
/*****************************************/
|
|
|
|
|
2019-02-17 09:09:22 +00:00
|
|
|
pat loc and ($1==0xff) && ($2==2)
|
|
|
|
with hl_or_de
|
|
|
|
yields %1.2
|
|
|
|
|
|
|
|
pat loc and ($1==0xffff) && ($2==2)
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat and $1==2
|
2019-02-13 19:56:10 +00:00
|
|
|
with hl_or_de smallpconst2
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
ani {const1, %2.num & 0xff}
|
|
|
|
yields a
|
|
|
|
with smallpconst2 hl_or_de
|
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
and 2
|
|
|
|
with hl_or_de smallnconst2
|
2019-02-08 21:38:07 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
ani {const1, %2.num & 0xff}
|
|
|
|
mov %1.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
2019-02-13 19:56:10 +00:00
|
|
|
with smallnconst2 hl_or_de
|
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
and 2
|
2019-02-08 21:38:07 +00:00
|
|
|
with hl_or_de const2
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
ani {const1, %2.num & 0xff}
|
|
|
|
mov %1.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a, %1.1
|
|
|
|
ani {const1, %2.num >> 8}
|
|
|
|
mov %1.1, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
|
|
|
with const2 hl_or_de
|
2019-02-13 19:56:10 +00:00
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
and 2
|
2019-02-08 21:38:07 +00:00
|
|
|
with hl_or_de hl_or_de
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
ana %2.2
|
|
|
|
mov %2.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a, %1.1
|
|
|
|
ana %2.1
|
|
|
|
mov %2.1, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %2
|
|
|
|
with hl_or_de hl_or_de
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%1.2
|
|
|
|
ana %2.2
|
|
|
|
mov %1.2,a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a,%1.1
|
|
|
|
ana %2.1
|
|
|
|
mov %1.1,a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat and defined($1)
|
2019-02-09 12:29:41 +00:00
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
lxi de,{const2,$1}
|
|
|
|
Call {label,".and"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat and !defined($1)
|
2019-02-09 12:29:41 +00:00
|
|
|
with dereg
|
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
Call {label,".and"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-17 09:09:22 +00:00
|
|
|
pat loc ior ($1==0)
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat ior $1==2
|
2019-02-13 19:56:10 +00:00
|
|
|
with hl_or_de smallpconst2
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
ori {const1, %2.num & 0xff}
|
|
|
|
mov %1.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-13 19:56:10 +00:00
|
|
|
yields %1
|
|
|
|
with smallpconst2 hl_or_de
|
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
ior 2
|
|
|
|
with hl_or_de smallnconst2
|
2019-02-08 21:38:07 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
ori {const1, %2.num & 0xff}
|
|
|
|
mov %1.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-13 19:56:10 +00:00
|
|
|
move {const1, 0xff}, %1.1
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
2019-02-13 19:56:10 +00:00
|
|
|
with smallnconst2 hl_or_de
|
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
ior 2
|
2019-02-08 21:38:07 +00:00
|
|
|
with hl_or_de const2
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
ori {const1, %2.num & 0xff}
|
|
|
|
mov %1.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a, %1.1
|
|
|
|
ori {const1, %2.num >> 8}
|
|
|
|
mov %1.1, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
|
|
|
with const2 hl_or_de
|
2019-02-13 19:56:10 +00:00
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
ior 2
|
2019-02-08 21:38:07 +00:00
|
|
|
with hl_or_de hl_or_de
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
ora %2.2
|
|
|
|
mov %2.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a, %1.1
|
|
|
|
ora %2.1
|
|
|
|
mov %2.1, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %2
|
|
|
|
with hl_or_de hl_or_de
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%1.2
|
|
|
|
ora %2.2
|
|
|
|
mov %1.2,a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a,%1.1
|
|
|
|
ora %2.1
|
|
|
|
mov %1.1,a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ior defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".ior"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ior !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".ior"}
|
|
|
|
|
2019-02-17 09:09:22 +00:00
|
|
|
pat loc xor ($1==0)
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat xor $1==2
|
2019-02-13 19:56:10 +00:00
|
|
|
with hl_or_de smallpconst2
|
2019-02-08 21:38:07 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
xri {const1, %2.num & 0xff}
|
|
|
|
mov %1.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
2019-02-13 19:56:10 +00:00
|
|
|
with smallpconst2 hl_or_de
|
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
xor 2
|
2019-02-08 21:38:07 +00:00
|
|
|
with hl_or_de const2
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
xri {const1, %2.num & 0xff}
|
|
|
|
mov %1.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a, %1.1
|
|
|
|
xri {const1, %2.num >> 8}
|
|
|
|
mov %1.1, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
|
|
|
with const2 hl_or_de
|
2019-02-13 19:56:10 +00:00
|
|
|
yields %1 %2
|
|
|
|
leaving
|
|
|
|
xor 2
|
2019-02-08 21:38:07 +00:00
|
|
|
with hl_or_de hl_or_de
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.2
|
|
|
|
xra %2.2
|
|
|
|
mov %2.2, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a, %1.1
|
|
|
|
xra %2.1
|
|
|
|
mov %2.1, a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %2
|
|
|
|
with hl_or_de hl_or_de
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%1.2
|
|
|
|
xra %2.2
|
|
|
|
mov %1.2,a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
mov a,%1.1
|
|
|
|
xra %2.1
|
|
|
|
mov %1.1,a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
2019-02-08 21:38:07 +00:00
|
|
|
yields %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat xor defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".xor"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat xor !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".xor"}
|
|
|
|
|
|
|
|
pat com $1==2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
uses areg
|
|
|
|
gen mov a,%1.2
|
|
|
|
cma.
|
|
|
|
mov %1.2,a
|
2019-03-08 22:06:34 +00:00
|
|
|
kill a
|
1985-01-17 14:31:34 +00:00
|
|
|
mov a,%1.1
|
|
|
|
cma.
|
|
|
|
mov %1.1,a yields %1
|
|
|
|
|
1985-02-01 12:51:56 +00:00
|
|
|
pat com defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".com"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
1985-02-01 12:51:56 +00:00
|
|
|
pat com !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
gen Call {label,".com"}
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat rol $1==2
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg hlreg
|
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
uses areg
|
|
|
|
gen mov a,e
|
|
|
|
ani {const1,15}
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,3f}
|
1985-01-17 14:31:34 +00:00
|
|
|
1:
|
|
|
|
dad hl
|
1985-03-04 13:42:38 +00:00
|
|
|
jnc {label,2f}
|
1985-01-17 14:31:34 +00:00
|
|
|
inr l
|
|
|
|
2:
|
|
|
|
dcr a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
3: yields hl
|
|
|
|
|
|
|
|
pat rol $1==4
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
gen Call {label,".rol4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ror $1==2
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg hlreg
|
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
uses areg
|
|
|
|
gen mov a,e
|
|
|
|
ani {const1,15}
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,2f}
|
1985-01-17 14:31:34 +00:00
|
|
|
mov e,a
|
|
|
|
mov a,l
|
|
|
|
1:
|
|
|
|
rar.
|
|
|
|
mov a,h
|
|
|
|
rar.
|
|
|
|
mov h,a
|
|
|
|
mov a,l
|
|
|
|
rar.
|
|
|
|
mov l,a
|
|
|
|
dcr e
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
2: yields hl
|
|
|
|
|
|
|
|
pat ror $1==4
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
gen Call {label,".ror4"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
/***********************************************/
|
|
|
|
/* Group 10: Set instructions */
|
|
|
|
/***********************************************/
|
|
|
|
|
|
|
|
pat inn $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
gen Call {label,".inn2"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
1985-02-01 12:51:56 +00:00
|
|
|
pat inn defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".inn"} yields de
|
1985-02-01 12:51:56 +00:00
|
|
|
|
|
|
|
pat inn !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
gen Call {label,".inn"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat set $1==2
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
gen Call {label,".set2"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat set defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".set"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat set !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".set"}
|
|
|
|
|
|
|
|
/***********************************************/
|
|
|
|
/* Group 11: Array instructions */
|
|
|
|
/***********************************************/
|
|
|
|
|
|
|
|
pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)==0 leaving adi 2
|
|
|
|
pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)!=0 leaving adi 2 adp 0-rom($1,1)
|
|
|
|
|
|
|
|
pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)==0
|
|
|
|
with hlreg
|
|
|
|
gen dad hl yields hl leaving adi 2
|
|
|
|
|
|
|
|
pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)!=0
|
|
|
|
with hlreg
|
|
|
|
uses dereg={const2,0-rom($1,1)}
|
|
|
|
gen dad de
|
|
|
|
dad hl yields hl leaving adi 2
|
|
|
|
|
|
|
|
pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)==0
|
|
|
|
with hlreg
|
|
|
|
gen dad hl
|
|
|
|
dad hl yields hl leaving adi 2
|
|
|
|
|
|
|
|
pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)!=0
|
|
|
|
with hlreg
|
|
|
|
uses dereg={const2,0-rom($1,1)}
|
|
|
|
gen dad de
|
|
|
|
dad hl
|
|
|
|
dad hl yields hl leaving adi 2
|
|
|
|
|
|
|
|
pat lae aar $2==2 && rom($1,3)==8 && rom($1,1)==0
|
|
|
|
with hlreg
|
|
|
|
gen dad hl
|
|
|
|
dad hl
|
|
|
|
dad hl yields hl leaving adi 2
|
|
|
|
|
|
|
|
pat lae aar $2==2 && rom($1,3)==8 && rom($1,1)!=0
|
|
|
|
with hlreg
|
|
|
|
uses dereg={const2,0-rom($1,1)}
|
|
|
|
gen dad de
|
|
|
|
dad hl
|
|
|
|
dad hl
|
|
|
|
dad hl yields hl leaving adi 2
|
|
|
|
|
|
|
|
pat lar $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".lar2"}
|
|
|
|
|
|
|
|
pat lar defined($1)
|
|
|
|
gen Call {label,"eunimpl"}
|
|
|
|
|
|
|
|
pat lar !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with hl_or_de
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,2}
|
|
|
|
cnz {label,"eunimpl"}
|
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
|
|
|
cnz {label,"eunimpl"}
|
|
|
|
Call {label,".lar2"}
|
|
|
|
|
|
|
|
pat sar $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".sar2"}
|
|
|
|
|
|
|
|
pat sar defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,"eunimpl"}
|
|
|
|
|
|
|
|
pat sar !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with hl_or_de
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,2}
|
|
|
|
cnz {label,"eunimpl"}
|
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
|
|
|
cnz {label,"eunimpl"}
|
|
|
|
Call {label,".sar2"}
|
|
|
|
|
|
|
|
pat aar $1==2
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".aar2"}
|
|
|
|
|
|
|
|
pat aar defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,"eunimpl"}
|
|
|
|
|
|
|
|
pat aar !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with hl_or_de
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,2}
|
|
|
|
cnz {label,"eunimpl"}
|
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
|
|
|
cnz {label,"eunimpl"}
|
|
|
|
Call {label,".aar2"}
|
|
|
|
|
|
|
|
/***********************************************/
|
|
|
|
/* Group 12: Compare instructions */
|
|
|
|
/***********************************************/
|
|
|
|
|
|
|
|
pat cmi $1==2 leaving sbi 2
|
|
|
|
|
|
|
|
pat cmi $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,1}
|
|
|
|
Call {label,".cmi4"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
1985-04-12 14:25:59 +00:00
|
|
|
pat cmf $1==4
|
2018-04-25 20:09:56 +00:00
|
|
|
leaving cal ".cmf4" asp 8 lfr 2
|
1985-04-12 14:25:59 +00:00
|
|
|
|
|
|
|
pat cmf $1==8
|
2018-04-25 20:09:56 +00:00
|
|
|
leaving cal ".cmf8" asp 16 lfr 2
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
|
2019-02-15 20:30:27 +00:00
|
|
|
pat cmu zlt $1==2
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de hl_or_de STACK
|
2019-02-15 20:30:27 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %2.2
|
|
|
|
sub %1.2
|
|
|
|
mov a, %2.1
|
|
|
|
sbb %1.1
|
|
|
|
jc {label, $2}
|
2019-02-15 20:38:17 +00:00
|
|
|
with const2 hl_or_de STACK
|
2019-02-15 20:30:27 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %2.2
|
2019-02-16 00:18:21 +00:00
|
|
|
sui {const1, %1.num & 0xff}
|
2019-02-15 20:30:27 +00:00
|
|
|
mov a, %2.1
|
|
|
|
sbi {const1, %1.num >> 8}
|
|
|
|
jc {label, $2}
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de const2 STACK
|
2019-02-15 20:30:27 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mvi a, {const1, %2.num & 0xff}
|
|
|
|
sub %1.2
|
|
|
|
mvi a, {const1, %2.num >> 8}
|
|
|
|
sbb %1.1
|
|
|
|
jc {label, $2}
|
|
|
|
|
|
|
|
pat cmu zgt $1==2
|
|
|
|
leaving
|
|
|
|
exg 2
|
|
|
|
cmu 2
|
|
|
|
zlt $2
|
|
|
|
|
|
|
|
pat cmu zge $1==2
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de hl_or_de STACK
|
2019-02-15 20:30:27 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %2.2
|
|
|
|
sub %1.2
|
|
|
|
mov a, %2.1
|
|
|
|
sbb %1.1
|
|
|
|
jnc {label, $2}
|
2019-02-15 20:38:17 +00:00
|
|
|
with const2 hl_or_de STACK
|
2019-02-15 20:30:27 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %2.2
|
2019-02-16 00:18:21 +00:00
|
|
|
sui {const1, %1.num & 0xff}
|
2019-02-15 20:30:27 +00:00
|
|
|
mov a, %2.1
|
|
|
|
sbi {const1, %1.num >> 8}
|
|
|
|
jnc {label, $2}
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de const2 STACK
|
2019-02-15 20:30:27 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mvi a, {const1, %2.num & 0xff}
|
|
|
|
sub %1.2
|
|
|
|
mvi a, {const1, %2.num >> 8}
|
|
|
|
sbb %1.1
|
|
|
|
jnc {label, $2}
|
|
|
|
|
|
|
|
pat cmu zle $1==2
|
|
|
|
leaving
|
|
|
|
exg 2
|
|
|
|
cmu 2
|
|
|
|
zge $2
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat cmu $1==2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
uses areg
|
|
|
|
gen mov a,%2.1
|
|
|
|
cmp %1.1
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,2f}
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
jc {label,1f}
|
1985-01-17 14:31:34 +00:00
|
|
|
0:
|
|
|
|
lxi %2,{const2,1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jmp {label,3f}
|
1985-01-17 14:31:34 +00:00
|
|
|
1:
|
|
|
|
lxi %2,{const2,0-1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jmp {label,3f}
|
1985-01-17 14:31:34 +00:00
|
|
|
2:
|
|
|
|
mov a,%2.2
|
|
|
|
cmp %1.2
|
1985-03-04 13:42:38 +00:00
|
|
|
jc {label,1b}
|
|
|
|
jnz {label,0b}
|
1985-01-17 14:31:34 +00:00
|
|
|
lxi %2,{const2,0}
|
|
|
|
3: yields %2
|
|
|
|
|
|
|
|
pat cmu $1==4
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen mvi a,{const1,0}
|
|
|
|
Call {label,".cmi4"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat cms $1==2 leaving cmi 2
|
|
|
|
|
|
|
|
pat cms defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".cms"} yields de
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat cms !defined($1)
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".cms"} yields de
|
|
|
|
|
|
|
|
pat cmp leaving cmu 2
|
|
|
|
|
|
|
|
pat tlt
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen mov a,%1.1
|
|
|
|
ral.
|
|
|
|
mvi a,{const1,0}
|
|
|
|
mov %1.1,a
|
|
|
|
adc a
|
|
|
|
mov %1.2,a yields %1
|
|
|
|
|
|
|
|
pat tle
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
|
|
|
uses hl_or_de={const2,1}, areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen xra a
|
|
|
|
add %1.1
|
1985-03-04 13:42:38 +00:00
|
|
|
jm {label,2f}
|
|
|
|
jnz {label,1f}
|
1985-01-17 14:31:34 +00:00
|
|
|
xra a
|
|
|
|
add %1.2
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,2f}
|
1985-01-17 14:31:34 +00:00
|
|
|
1:
|
|
|
|
dcx %a
|
|
|
|
2: yields %a
|
|
|
|
|
|
|
|
pat teq
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen mov a,%1.1
|
|
|
|
ora %1.2
|
|
|
|
move {const2,0},%1
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-01-17 14:31:34 +00:00
|
|
|
inx %1
|
|
|
|
1: yields %1
|
|
|
|
|
|
|
|
pat tne
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen mov a,%1.1
|
|
|
|
ora %1.2
|
|
|
|
move {const2,0},%1
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,1f}
|
1985-01-17 14:31:34 +00:00
|
|
|
inx %1
|
|
|
|
1: yields %1
|
|
|
|
|
|
|
|
pat tge
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen mov a,%1.1
|
|
|
|
ral.
|
|
|
|
cmc.
|
|
|
|
mvi a,{const1,0}
|
|
|
|
mov %1.1,a
|
|
|
|
adc a
|
|
|
|
mov %1.2,a yields %1
|
|
|
|
|
|
|
|
pat tgt
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
|
|
|
uses hl_or_de={const2,0}, areg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen xra a
|
|
|
|
add %1.1
|
1985-03-04 13:42:38 +00:00
|
|
|
jm {label,2f}
|
|
|
|
jnz {label,1f}
|
1985-01-17 14:31:34 +00:00
|
|
|
xra a
|
|
|
|
add %1.2
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,2f}
|
1985-01-17 14:31:34 +00:00
|
|
|
1:
|
|
|
|
inx %a
|
|
|
|
2: yields %a
|
|
|
|
|
|
|
|
pat loc cmi teq and $1>=0 && $1<=255 && $2==2 && $4==2
|
1985-03-04 13:42:38 +00:00
|
|
|
with exact areg hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,1f}
|
1985-01-17 14:31:34 +00:00
|
|
|
move {const2,0},%2
|
|
|
|
1: yields %2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,2f}
|
1985-02-01 12:51:56 +00:00
|
|
|
1:
|
|
|
|
move {const2,0},%2
|
|
|
|
2: yields %2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc cmi tne and $1>=0 && $1<=255 && $2==2 && $4==2
|
1985-03-04 13:42:38 +00:00
|
|
|
with exact areg hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-01-17 14:31:34 +00:00
|
|
|
move {const2,0},%2
|
|
|
|
1: yields %2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
move {const2,0},%2
|
|
|
|
1: yields %2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc cmi teq ior $1>=0 && $1<=255 && $2==2 && $4==2
|
1985-03-04 13:42:38 +00:00
|
|
|
with exact areg hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
move {const2,1},%2
|
|
|
|
1: yields %2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
move {const2,1},%2
|
1985-01-17 14:31:34 +00:00
|
|
|
1: yields %2
|
|
|
|
|
|
|
|
pat loc cmi tne ior $1>=0 && $1<=255 && $2==2 && $4==2
|
1985-03-04 13:42:38 +00:00
|
|
|
with exact areg hl_or_de
|
1985-01-17 14:31:34 +00:00
|
|
|
gen cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
move {const2,1},%2
|
1985-01-17 14:31:34 +00:00
|
|
|
1: yields %2
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg
|
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,2f}
|
1985-02-01 12:51:56 +00:00
|
|
|
1:
|
|
|
|
move {const2,1},%2
|
|
|
|
2: yields %2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc cmi teq $1>=0 && $1<=255 && $2==2
|
|
|
|
with exact areg
|
1985-03-04 13:42:38 +00:00
|
|
|
uses hl_or_de={const2,0}
|
1985-01-17 14:31:34 +00:00
|
|
|
gen cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-01-22 19:55:11 +00:00
|
|
|
inx %a
|
|
|
|
1: yields %a
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
|
|
|
uses hl_or_de={const2,0}, areg
|
1985-02-01 12:51:56 +00:00
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
inx %a
|
|
|
|
1: yields %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
pat loc cmi tne $1>=0 && $1<=255 && $2==2
|
|
|
|
with exact areg
|
1985-03-04 13:42:38 +00:00
|
|
|
uses hl_or_de={const2,0}
|
1985-01-17 14:31:34 +00:00
|
|
|
gen cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jz {label,1f}
|
1985-01-22 19:55:11 +00:00
|
|
|
inx %a
|
|
|
|
1: yields %a
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de
|
|
|
|
uses hl_or_de={const2,1}, areg
|
1985-02-01 12:51:56 +00:00
|
|
|
gen mov a,%1.2
|
|
|
|
cpi {const1,$1}
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1f}
|
1985-02-01 12:51:56 +00:00
|
|
|
dcx %a
|
|
|
|
1: yields %a
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat loc cmi $1>=0 && $1<=255 && $2==2
|
|
|
|
with exact areg
|
1985-03-04 13:42:38 +00:00
|
|
|
uses hl_or_de
|
1985-02-01 12:51:56 +00:00
|
|
|
gen sui {const1,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
mov %a.2,a
|
|
|
|
rar.
|
|
|
|
mov %a.1,a yields %a
|
|
|
|
with yields {const2,$1}
|
|
|
|
leaving cmi 2
|
|
|
|
|
|
|
|
pat loc cmi $1<0 && $2==2
|
|
|
|
with exact areg yields {const2,0-1}
|
|
|
|
with yields {const2,$1}
|
|
|
|
leaving cmi 2
|
|
|
|
|
|
|
|
/*******************************************/
|
|
|
|
/* Group 13: Branch instructions */
|
|
|
|
/*******************************************/
|
|
|
|
|
1985-03-18 10:00:30 +00:00
|
|
|
pat loc beq $1>=0 && $1<=255
|
|
|
|
with exact reg
|
|
|
|
uses reusing %1, areg=%1
|
|
|
|
gen cpi {const1,$1}
|
|
|
|
jz {label,$2}
|
|
|
|
with yields {const2,$1}
|
|
|
|
leaving beq $2
|
|
|
|
|
|
|
|
pat loc bne $1>=0 && $1<=255
|
|
|
|
with exact reg
|
|
|
|
uses reusing %1, areg=%1
|
|
|
|
gen cpi {const1,$1}
|
|
|
|
jnz {label,$2}
|
|
|
|
with yields {const2,$1}
|
|
|
|
leaving bne $2
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat bra
|
2019-02-10 18:22:43 +00:00
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
jmp {label,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat blt
|
2019-02-14 22:57:55 +00:00
|
|
|
with hlreg dereg STACK
|
2019-02-10 18:22:43 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
2019-02-14 23:38:39 +00:00
|
|
|
#ifdef USE_I80_RSTS
|
|
|
|
rst {const1, 5}
|
|
|
|
#else
|
|
|
|
Call {label, ".cmps_mag"}
|
|
|
|
#endif
|
2019-02-15 20:30:27 +00:00
|
|
|
jc {label, $1}
|
2019-02-10 18:22:43 +00:00
|
|
|
|
|
|
|
pat bgt
|
|
|
|
leaving
|
|
|
|
exg 2
|
|
|
|
blt $1
|
2019-02-10 18:40:48 +00:00
|
|
|
|
2019-02-10 18:22:43 +00:00
|
|
|
pat bge
|
2019-02-14 22:57:55 +00:00
|
|
|
with hlreg dereg STACK
|
2019-02-10 18:22:43 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
2019-02-14 23:38:39 +00:00
|
|
|
#ifdef USE_I80_RSTS
|
|
|
|
rst {const1, 5}
|
|
|
|
#else
|
|
|
|
Call {label, ".cmps_mag"}
|
|
|
|
#endif
|
2019-02-15 20:30:27 +00:00
|
|
|
jnc {label, $1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ble
|
2019-02-10 18:22:43 +00:00
|
|
|
leaving
|
|
|
|
exg 2
|
|
|
|
bge $1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat beq
|
2019-02-10 18:22:43 +00:00
|
|
|
with const2 hl_or_de STACK
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %2.2
|
|
|
|
cpi {const1, %1.num & 0xff}
|
|
|
|
jnz {label, 1f}
|
|
|
|
mov a, %2.1
|
|
|
|
cpi {const1, %1.num >> 8}
|
|
|
|
jz {label, $1}
|
|
|
|
1:
|
|
|
|
with hl_or_de const2 STACK
|
|
|
|
leaving
|
|
|
|
exg 2
|
|
|
|
beq $1
|
|
|
|
with hl_or_de hl_or_de STACK
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%2.2
|
|
|
|
cmp %1.2
|
|
|
|
jnz {label,1f}
|
|
|
|
mov a,%2.1
|
|
|
|
cmp %1.1
|
|
|
|
jz {label,$1}
|
|
|
|
1:
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat bne
|
2019-02-10 18:22:43 +00:00
|
|
|
with const2 hl_or_de STACK
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %2.2
|
|
|
|
cpi {const1, %1.num & 0xff}
|
|
|
|
jnz {label, $1}
|
|
|
|
mov a, %2.1
|
|
|
|
cpi {const1, %1.num >> 8}
|
|
|
|
jnz {label, $1}
|
|
|
|
with hl_or_de const2 STACK
|
|
|
|
leaving
|
|
|
|
exg 2
|
|
|
|
beq $1
|
|
|
|
with hl_or_de hl_or_de STACK
|
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%2.2
|
|
|
|
cmp %1.2
|
|
|
|
jnz {label,$1}
|
|
|
|
mov a,%2.1
|
|
|
|
cmp %1.1
|
|
|
|
jnz {label,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat zlt
|
2019-02-14 23:38:39 +00:00
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
pop psw
|
|
|
|
ora a
|
|
|
|
jm {label,$1}
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de STACK
|
2019-02-14 23:38:39 +00:00
|
|
|
gen
|
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
|
|
|
jm {label,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat zle
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de STACK
|
2019-02-14 23:38:39 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.1
|
|
|
|
ora a
|
|
|
|
jm {label, $1}
|
|
|
|
jnz {label, 1f}
|
|
|
|
ora %1.2
|
|
|
|
jz {label, $1}
|
|
|
|
1:
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat zeq
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de STACK
|
2019-02-14 23:38:39 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%1.1
|
|
|
|
ora %1.2
|
|
|
|
jz {label,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat zne
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de STACK
|
2019-02-14 23:38:39 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%1.1
|
|
|
|
ora %1.2
|
|
|
|
jnz {label,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat zge
|
2019-02-14 23:38:39 +00:00
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
pop psw
|
|
|
|
ral.
|
|
|
|
jnc {label,$1}
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de STACK
|
2019-02-14 23:38:39 +00:00
|
|
|
gen
|
|
|
|
mov a,%1.1
|
|
|
|
ora a
|
|
|
|
jp {label,$1}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat zgt
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de STACK
|
2019-02-14 23:38:39 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a, %1.1
|
|
|
|
ora a
|
|
|
|
jm {label, 1f}
|
|
|
|
jnz {label, $1}
|
|
|
|
ora %1.2
|
|
|
|
jnz {label, $1}
|
|
|
|
1:
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lol zeq
|
2019-02-09 12:29:41 +00:00
|
|
|
with STACK
|
|
|
|
uses hlreg={const2,$1}, areg
|
|
|
|
gen
|
|
|
|
dad lb
|
|
|
|
mov a,{m}
|
|
|
|
inx hl
|
|
|
|
ora {m}
|
|
|
|
jz {label,$2}
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat lol zne
|
2019-02-09 12:29:41 +00:00
|
|
|
with STACK
|
2019-02-12 21:19:07 +00:00
|
|
|
uses hlreg={const2,$1}, areg
|
|
|
|
gen
|
|
|
|
dad lb
|
|
|
|
mov a,{m}
|
|
|
|
inx hl
|
|
|
|
ora {m}
|
|
|
|
jnz {label,$2}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ior zeq $1==2
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de hl_or_de STACK
|
2019-02-14 23:38:39 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%1.1
|
|
|
|
ora %1.2
|
|
|
|
ora %2.1
|
|
|
|
ora %2.2
|
|
|
|
jz {label,$2}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ior zne $1==2
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de hl_or_de STACK
|
2019-02-14 23:38:39 +00:00
|
|
|
uses areg
|
|
|
|
gen
|
|
|
|
mov a,%1.1
|
|
|
|
ora %1.2
|
|
|
|
ora %2.1
|
|
|
|
ora %2.2
|
|
|
|
jnz {label,$2}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
/*********************************************/
|
|
|
|
/* Group 14: Procedure call instructions */
|
|
|
|
/*********************************************/
|
|
|
|
|
|
|
|
pat cal
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,$1}
|
|
|
|
|
|
|
|
pat cai
|
1987-11-10 13:49:04 +00:00
|
|
|
with hlreg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
2019-02-06 19:36:23 +00:00
|
|
|
gen Call {label, ".pchl"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lfr $1==2 yields de
|
|
|
|
|
|
|
|
pat lfr $1<=8
|
|
|
|
with STACK
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg={const1,$1/2}, hlreg={label,".fra"+$1}, dereg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen 1:
|
|
|
|
dcx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov d,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
dcx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov e,{m}
|
1985-01-17 14:31:34 +00:00
|
|
|
push de
|
|
|
|
dcr a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat lfr ret $1==$2 leaving ret 0
|
|
|
|
|
|
|
|
pat ret $1==0
|
|
|
|
with STACK
|
|
|
|
uses hlreg
|
2019-02-06 07:08:11 +00:00
|
|
|
gen jmp {label, ".ret"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ret $1==2
|
|
|
|
with dereg STACK
|
|
|
|
uses hlreg
|
2019-02-06 07:08:11 +00:00
|
|
|
gen jmp {label, ".ret"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat ret $1<=8
|
|
|
|
with STACK
|
1985-02-01 12:51:56 +00:00
|
|
|
uses areg={const1,$1/2}, hlreg={label,".fra"}, dereg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen 1:
|
|
|
|
pop de
|
1985-03-04 13:42:38 +00:00
|
|
|
mov {m},e
|
1985-01-17 14:31:34 +00:00
|
|
|
inx hl
|
1985-03-04 13:42:38 +00:00
|
|
|
mov {m},d
|
1985-01-17 14:31:34 +00:00
|
|
|
inx hl
|
|
|
|
dcr a
|
1985-03-04 13:42:38 +00:00
|
|
|
jnz {label,1b}
|
2019-02-06 07:08:11 +00:00
|
|
|
jmp {label, ".ret"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
/******************************************/
|
|
|
|
/* Group 15: Miscellaneous */
|
|
|
|
/******************************************/
|
|
|
|
|
2019-02-13 23:05:08 +00:00
|
|
|
pat asp $1==0 /* do nothing */
|
|
|
|
|
|
|
|
pat asp ($1==2)
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de
|
2019-02-10 17:57:20 +00:00
|
|
|
with STACK
|
2019-02-13 23:05:08 +00:00
|
|
|
uses hlreg
|
2019-02-10 17:57:20 +00:00
|
|
|
gen
|
2019-02-13 23:05:08 +00:00
|
|
|
pop hl
|
|
|
|
|
|
|
|
pat asp ($1==4)
|
2019-02-15 20:38:17 +00:00
|
|
|
with hl_or_de hl_or_de
|
2019-02-13 23:05:08 +00:00
|
|
|
with STACK
|
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
pop hl
|
|
|
|
pop hl
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-10 17:57:20 +00:00
|
|
|
pat asp ($1<0) && ($1>0-12)
|
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
push hl
|
|
|
|
leaving
|
|
|
|
asp $1+2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-13 23:05:08 +00:00
|
|
|
pat asp ($1>4) && ($1<12)
|
2019-02-10 17:57:20 +00:00
|
|
|
with STACK
|
|
|
|
uses hlreg
|
|
|
|
gen
|
|
|
|
pop hl
|
|
|
|
leaving
|
|
|
|
asp $1-2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
2019-02-13 23:05:08 +00:00
|
|
|
pat asp
|
|
|
|
with STACK
|
|
|
|
uses hlreg={const2,$1}
|
|
|
|
gen
|
|
|
|
dad sp
|
|
|
|
sphl.
|
|
|
|
|
1985-01-17 14:31:34 +00:00
|
|
|
pat ass $1==2
|
|
|
|
with hlreg STACK
|
|
|
|
gen dad sp
|
|
|
|
sphl.
|
|
|
|
|
|
|
|
pat blm
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".blm"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat bls
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".blm"}
|
|
|
|
|
|
|
|
pat csa
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen jmp {label,".csa"}
|
|
|
|
|
|
|
|
pat csb
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen jmp {label,".csb"}
|
|
|
|
|
|
|
|
pat dch leaving loi 2
|
|
|
|
|
|
|
|
pat dup $1==2
|
1985-02-01 12:51:56 +00:00
|
|
|
with src1or2 yields %1 %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat dup $1==4
|
1985-02-01 12:51:56 +00:00
|
|
|
with src1or2 src1or2 yields %2 %1 %2 %1
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat dup
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".dup"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat dus $1==2
|
1987-11-10 13:49:04 +00:00
|
|
|
with dereg
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".dup"}
|
|
|
|
|
|
|
|
pat exg $1==2
|
1985-02-01 12:51:56 +00:00
|
|
|
with src1or2 src1or2 yields %1 %2
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat exg defined($1)
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for
"0123456789abcdef"[code & 0xf]
The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'. The rule for '.and' was
pat and defined($1)
kills ALL
uses dereg={const2,$1}
gen Call {label,".and"}
This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.
Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register. This is like the i86 table. A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.
Also correct 1 to $1 when calling '.exg'.
2017-12-07 03:14:00 +00:00
|
|
|
gen lxi de,{const2,$1}
|
|
|
|
Call {label,".exg"}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat fil
|
1985-03-04 13:42:38 +00:00
|
|
|
uses hlreg={label,$1}
|
|
|
|
gen shld {label,"hol0"+4}
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat gto
|
|
|
|
with STACK
|
|
|
|
gen lhld {label,$1+2}
|
|
|
|
sphl.
|
|
|
|
lhld {label,$1+4}
|
|
|
|
move hl,lb
|
|
|
|
lhld {label,$1}
|
|
|
|
pchl.
|
|
|
|
|
|
|
|
pat lim
|
1985-02-01 12:51:56 +00:00
|
|
|
uses hlreg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen lhld {label,".ignmask"} yields hl
|
|
|
|
|
|
|
|
pat lin
|
|
|
|
uses hlreg={const2,$1}
|
|
|
|
gen shld {label,"hol0"}
|
|
|
|
|
|
|
|
pat lni
|
1985-02-01 12:51:56 +00:00
|
|
|
uses hlreg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen lhld {label,"hol0"}
|
|
|
|
inx hl
|
|
|
|
shld {label,"hol0"}
|
|
|
|
|
|
|
|
pat lor $1==0 yields lb
|
|
|
|
|
|
|
|
pat lor $1==1
|
|
|
|
with STACK
|
|
|
|
uses hlreg={const2,0}
|
|
|
|
gen dad sp yields hl
|
|
|
|
|
|
|
|
pat lor $1==2
|
1985-02-01 12:51:56 +00:00
|
|
|
uses hlreg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen lhld {label,".reghp"} yields hl
|
|
|
|
|
|
|
|
pat lpb leaving adp SL
|
|
|
|
|
|
|
|
pat mon
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".mon"}
|
|
|
|
|
|
|
|
pat nop
|
1987-08-26 13:47:37 +00:00
|
|
|
kills ALL
|
1991-09-04 10:55:52 +00:00
|
|
|
#ifdef DEBUG
|
1985-01-17 14:31:34 +00:00
|
|
|
gen Call {label,".nop"}
|
1991-09-04 10:55:52 +00:00
|
|
|
#endif
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat rck
|
1985-03-04 13:42:38 +00:00
|
|
|
with hl_or_de STACK
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat rtt leaving ret 0
|
|
|
|
|
|
|
|
pat sig
|
|
|
|
with dereg
|
1985-02-01 12:51:56 +00:00
|
|
|
uses hlreg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen lhld {label,".trapproc"}
|
|
|
|
xchg.
|
|
|
|
shld {label,".trapproc"} yields de
|
|
|
|
with STACK
|
1985-02-01 12:51:56 +00:00
|
|
|
uses hlreg
|
1985-01-17 14:31:34 +00:00
|
|
|
gen lhld {label,".trapproc"}
|
|
|
|
xthl.
|
|
|
|
shld {label,".trapproc"}
|
|
|
|
|
|
|
|
pat sim
|
|
|
|
with hlreg
|
|
|
|
gen shld {label,".ignmask"}
|
|
|
|
|
|
|
|
pat str $1==0
|
|
|
|
with localbase
|
|
|
|
|
|
|
|
pat str $1==1
|
1985-02-01 12:51:56 +00:00
|
|
|
with hlreg
|
|
|
|
gen sphl.
|
1985-01-17 14:31:34 +00:00
|
|
|
|
|
|
|
pat str $1==2
|
|
|
|
with hlreg
|
|
|
|
gen shld {label,".reghp"}
|
|
|
|
|
|
|
|
pat trp
|
2019-06-11 18:02:03 +00:00
|
|
|
with areg
|
|
|
|
kills ALL
|
|
|
|
gen Call {label,".trp"}
|