From fd5b186f8ad455b205a692ce3c0ecf4c659f25d2 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 12 Feb 2019 23:49:54 +0100 Subject: [PATCH] Rework the code generator not to use BC for the frame pointer. Star Trek is up from 40243 to 40539 bytes. --- mach/i80/libem/aar2.s | 6 -- mach/i80/libem/and.s | 6 -- mach/i80/libem/blm.s | 6 -- mach/i80/libem/cii.s | 7 +- mach/i80/libem/cmi4.s | 6 -- mach/i80/libem/csa.s | 3 - mach/i80/libem/csb.s | 3 +- mach/i80/libem/dup.s | 6 -- mach/i80/libem/dvi2.s | 8 +- mach/i80/libem/dvi4.s | 7 +- mach/i80/libem/exg.s | 6 -- mach/i80/libem/inn.s | 6 -- mach/i80/libem/ior.s | 6 -- mach/i80/libem/lar2.s | 7 +- mach/i80/libem/loi.s | 7 +- mach/i80/libem/mli4.s | 6 -- mach/i80/libem/mlu2.s | 6 -- mach/i80/libem/pro.s | 31 ++++--- mach/i80/libem/rck.s | 6 -- mach/i80/libem/ret.s | 6 +- mach/i80/libem/rol4.s | 6 -- mach/i80/libem/ror4.s | 6 -- mach/i80/libem/rst.s | 25 +++-- mach/i80/libem/sar2.s | 7 +- mach/i80/libem/sbi4.s | 6 -- mach/i80/libem/set.s | 6 -- mach/i80/libem/sli4.s | 6 -- mach/i80/libem/sri4.s | 6 -- mach/i80/libem/sti.s | 7 +- mach/i80/libem/xor.s | 6 -- mach/i80/ncg/table | 211 +++++++++++++++++++++++------------------- plat/cpm/boot.s | 2 + 32 files changed, 160 insertions(+), 279 deletions(-) diff --git a/mach/i80/libem/aar2.s b/mach/i80/libem/aar2.s index 0453fa0ae..6da75ec93 100644 --- a/mach/i80/libem/aar2.s +++ b/mach/i80/libem/aar2.s @@ -14,9 +14,6 @@ .aar2: pop h shld .retadr1 - mov h,b - mov l,c - shld .bcreg pop h ! hl = pointer to descriptor pop d ! de = index @@ -40,8 +37,5 @@ dad d ! hl = address of array[index] push h - lhld .bcreg - mov b,h - mov c,l lhld .retadr1 pchl diff --git a/mach/i80/libem/and.s b/mach/i80/libem/and.s index 59a0253c6..1d0fc5e2c 100644 --- a/mach/i80/libem/and.s +++ b/mach/i80/libem/and.s @@ -12,9 +12,6 @@ .and: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg lxi h,0 dad sp @@ -35,8 +32,5 @@ pop h sphl - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/blm.s b/mach/i80/libem/blm.s index 0ff5b91cd..5672fceb2 100644 --- a/mach/i80/libem/blm.s +++ b/mach/i80/libem/blm.s @@ -12,9 +12,6 @@ .blm: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop h ! hl = destination address pop b ! bc = source address @@ -28,9 +25,6 @@ ora e jnz 1b - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/cii.s b/mach/i80/libem/cii.s index bf4e7efb8..9b342052c 100644 --- a/mach/i80/libem/cii.s +++ b/mach/i80/libem/cii.s @@ -15,9 +15,6 @@ .cii: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg sta .areg ! save a-register pop b @@ -82,8 +79,6 @@ shrink: mov l,b ! load destination size in hl jnz 1b sphl -3: lhld .bcreg - mov b,h - mov c,l +3: lhld .retadr pchl diff --git a/mach/i80/libem/cmi4.s b/mach/i80/libem/cmi4.s index 84c7c7d7f..fe9d62ce4 100644 --- a/mach/i80/libem/cmi4.s +++ b/mach/i80/libem/cmi4.s @@ -15,9 +15,6 @@ .cmi4: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg lxi b,4 lxi h,0 @@ -64,8 +61,5 @@ dad sp sphl - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/csa.s b/mach/i80/libem/csa.s index 9470481db..91458e9e9 100644 --- a/mach/i80/libem/csa.s +++ b/mach/i80/libem/csa.s @@ -14,7 +14,6 @@ .csa: pop h !hl = address of case descriptor pop d !de = index - push b !save localbase mov c,m inx h mov b,m @@ -45,13 +44,11 @@ ora h jz 1f !get default pointer if pointer = 0 pop b !remove default pointer - pop b !localbase pchl !jump!!!! 1: pop h !get default pointer mov a,l ora h cz ecase !trap - pop b !restore localbase pchl !jump!!!! diff --git a/mach/i80/libem/csb.s b/mach/i80/libem/csb.s index 7813c8b3c..4da4a87b9 100644 --- a/mach/i80/libem/csb.s +++ b/mach/i80/libem/csb.s @@ -14,7 +14,6 @@ .csb: pop h !hl = pointer to descriptor pop d !de = case index - push b !save localbase mov c,m !bc = default pointer inx h mov b,m @@ -50,7 +49,7 @@ jmp 1b 4: pop h !take default exit -5: pop b !restore localbase +5: mov a,l !jump address is zero? ora h cz ecase !trap diff --git a/mach/i80/libem/dup.s b/mach/i80/libem/dup.s index 50e0cc8cd..d35efd5c8 100644 --- a/mach/i80/libem/dup.s +++ b/mach/i80/libem/dup.s @@ -14,9 +14,6 @@ pop h shld .retadr - mov h,b - mov l,c - shld .bcreg mov h,d mov l,e @@ -32,8 +29,5 @@ ora e jnz 1b - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/dvi2.s b/mach/i80/libem/dvi2.s index 7498d98d8..3129c2a9b 100644 --- a/mach/i80/libem/dvi2.s +++ b/mach/i80/libem/dvi2.s @@ -19,9 +19,6 @@ .dvi2: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg sta .areg pop b ! bc = divisor @@ -112,8 +109,5 @@ 7: mov d,h ! return remainder mov e,l -8: lhld .bcreg - mov b,h - mov c,l - lhld .retadr +8: lhld .retadr pchl diff --git a/mach/i80/libem/dvi4.s b/mach/i80/libem/dvi4.s index a25806d06..407908d5f 100644 --- a/mach/i80/libem/dvi4.s +++ b/mach/i80/libem/dvi4.s @@ -18,9 +18,6 @@ .dvi4: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg sta .areg pop h ! store divisor @@ -129,9 +126,7 @@ dv0: lxi h,block1 ! left shift: block2 <- block1 <- 0 lhld block2 push h -5: lhld .bcreg - mov b,h - mov c,l +5: lhld .retadr pchl diff --git a/mach/i80/libem/exg.s b/mach/i80/libem/exg.s index 8a345b0f6..c5cfbf591 100644 --- a/mach/i80/libem/exg.s +++ b/mach/i80/libem/exg.s @@ -13,9 +13,6 @@ cc eoddz !trap if numer of bytes is odd pop h shld .retadr - mov h,b - mov l,c - shld .bcreg lxi h,0 dad sp @@ -38,8 +35,5 @@ jnz 1b pop d - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/inn.s b/mach/i80/libem/inn.s index c39b87582..fa5a09115 100644 --- a/mach/i80/libem/inn.s +++ b/mach/i80/libem/inn.s @@ -14,9 +14,6 @@ .inn: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop h xchg !hl = size, de = bit number @@ -58,9 +55,6 @@ dad sp sphl - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/ior.s b/mach/i80/libem/ior.s index cd7793bc1..2746b41e8 100644 --- a/mach/i80/libem/ior.s +++ b/mach/i80/libem/ior.s @@ -13,9 +13,6 @@ .ior: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg lxi h,0 dad sp @@ -36,8 +33,5 @@ pop h sphl - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/lar2.s b/mach/i80/libem/lar2.s index 82658ffbe..82a18bce9 100644 --- a/mach/i80/libem/lar2.s +++ b/mach/i80/libem/lar2.s @@ -15,9 +15,6 @@ .lar2: pop h shld .retadr1 - mov h,b - mov l,c - shld .bcreg pop h ! hl = pointer to descriptor pop d ! de = index @@ -69,8 +66,6 @@ ora c jnz 1b -2: lhld .bcreg - mov b,h - mov c,l +2: lhld .retadr1 pchl diff --git a/mach/i80/libem/loi.s b/mach/i80/libem/loi.s index 6eebb8704..15104b1c2 100644 --- a/mach/i80/libem/loi.s +++ b/mach/i80/libem/loi.s @@ -13,9 +13,6 @@ .loi: pop h shld .retadr - mov l,c ! free bc for scratch - mov h,b - shld .bcreg pop h ! hl = base address dad d ! hl = load pointer @@ -48,8 +45,6 @@ ora e jnz 1b -2: lhld .bcreg - mov c,l - mov b,h +2: lhld .retadr pchl diff --git a/mach/i80/libem/mli4.s b/mach/i80/libem/mli4.s index eab29ddcd..a33ab7cb9 100644 --- a/mach/i80/libem/mli4.s +++ b/mach/i80/libem/mli4.s @@ -11,9 +11,6 @@ .mli4: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop h ! store multiplier shld block1 @@ -70,8 +67,5 @@ lp2: rar lhld block3 push h - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/mlu2.s b/mach/i80/libem/mlu2.s index 4f4b700f7..498485a9a 100644 --- a/mach/i80/libem/mlu2.s +++ b/mach/i80/libem/mlu2.s @@ -14,9 +14,6 @@ .mlu2: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop b ! bc = multiplier pop d ! de = multiplicand @@ -44,8 +41,5 @@ 3: xchg ! de becomes product - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/pro.s b/mach/i80/libem/pro.s index 0c5fa3f22..19e46dd68 100644 --- a/mach/i80/libem/pro.s +++ b/mach/i80/libem/pro.s @@ -10,8 +10,8 @@ ! BC is used as the frame pointer, but HL and DE can be corrupted. .proword: - pop h - push b + lhld .fp + xthl mov e, m inx h mov d, m @@ -19,40 +19,41 @@ jmp .pron .probyte: - pop h - push b + lhld .fp + xthl mvi d, 0xff mov e, m inx h jmp .pron .pro4: - pop h - push b + lhld .fp + xthl lxi d, -4 jmp .pron .pro2: - pop h - push b + lhld .fp + xthl lxi d, -2 jmp .pron .pro0: - pop h - push b + lhld .fp + xthl lxi d, 0 ! fall through .pron: - shld .retadr - ! Copy the current stack pointer to BC. - lxi h, 0 - dad sp mov b, h mov c, l + ! Copy the current stack pointer to the frame pointer. + lxi h, 0 + dad sp + shld .fp ! Calculate the new stack pointer. dad d sphl - lhld .retadr + mov h, b + mov l, c pchl diff --git a/mach/i80/libem/rck.s b/mach/i80/libem/rck.s index d7c85c91c..4207634bc 100644 --- a/mach/i80/libem/rck.s +++ b/mach/i80/libem/rck.s @@ -13,9 +13,6 @@ .rck: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop h ! hl = return address pop d ! de = index @@ -50,8 +47,5 @@ 1: xra d ! now a = b 2: cm erange ! trap if index is too large - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/ret.s b/mach/i80/libem/ret.s index 8c08e97ed..131276fdc 100644 --- a/mach/i80/libem/ret.s +++ b/mach/i80/libem/ret.s @@ -6,9 +6,9 @@ .define .ret .ret: - mov h, b - mov l, c + lhld .fp sphl - pop b + pop h + shld .fp ret diff --git a/mach/i80/libem/rol4.s b/mach/i80/libem/rol4.s index 41219ea0c..607c16193 100644 --- a/mach/i80/libem/rol4.s +++ b/mach/i80/libem/rol4.s @@ -12,9 +12,6 @@ .rol4: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop h ! low-order bytes of operand pop b ! high order bytes of operand @@ -45,8 +42,5 @@ 2: push b push h - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/ror4.s b/mach/i80/libem/ror4.s index 490c75abc..c77665f64 100644 --- a/mach/i80/libem/ror4.s +++ b/mach/i80/libem/ror4.s @@ -12,9 +12,6 @@ .ror4: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop h ! low-order bytes of operand pop b ! high order bytes of operand @@ -45,8 +42,5 @@ 2: push b push h - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/rst.s b/mach/i80/libem/rst.s index a5234bd67..bedb9b574 100644 --- a/mach/i80/libem/rst.s +++ b/mach/i80/libem/rst.s @@ -19,8 +19,11 @@ shld 0x19 ret - ! de = [bc+const1] (remember bc is the frame pointer) + ! de = [fp+const1] rst1: + lhld .fp + xchg + pop h mov a, m inx h @@ -31,14 +34,17 @@ rst1: sbb a mov h, a - dad b + dad d mov e, m inx h mov d, m ret - ! [bc+const1] = de (remember bc is the frame pointer) + ! [fp+const1] = bc rst2: + lhld .fp + xchg + pop h mov a, m inx h @@ -49,14 +55,17 @@ rst2: sbb a mov h, a - dad b - mov m, e + dad d + mov m, c inx h - mov m, d + mov m, b ret - ! hl = bc+const1 + ! hl = fp+const1 rst3: + lhld .fp + xchg + pop h mov a, m inx h @@ -67,6 +76,6 @@ rst3: sbb a mov h, a - dad b + dad d ret diff --git a/mach/i80/libem/sar2.s b/mach/i80/libem/sar2.s index 6e1694ed3..7ffc1fbee 100644 --- a/mach/i80/libem/sar2.s +++ b/mach/i80/libem/sar2.s @@ -15,9 +15,6 @@ .sar2: pop h shld .retadr1 - mov h,b - mov l,c - shld .bcreg pop h ! hl = pointer to descriptor pop d ! de = index @@ -66,8 +63,6 @@ ora c jnz 1b -2: lhld .bcreg - mov b,h - mov c,l +2: lhld .retadr1 pchl diff --git a/mach/i80/libem/sbi4.s b/mach/i80/libem/sbi4.s index 7cf0e9c44..895baa017 100644 --- a/mach/i80/libem/sbi4.s +++ b/mach/i80/libem/sbi4.s @@ -12,9 +12,6 @@ .sbi4: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg lxi h,0 dad sp !now hl points to the first operand @@ -35,8 +32,5 @@ jnz 1b sphl - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/set.s b/mach/i80/libem/set.s index 3f47829e5..e2f7a3e93 100644 --- a/mach/i80/libem/set.s +++ b/mach/i80/libem/set.s @@ -12,9 +12,6 @@ .set: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg mov a,e rar @@ -63,8 +60,5 @@ 2: mov m,a - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/sli4.s b/mach/i80/libem/sli4.s index b791aae9b..523b0bb93 100644 --- a/mach/i80/libem/sli4.s +++ b/mach/i80/libem/sli4.s @@ -13,9 +13,6 @@ .sli4: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop b !number of shifts pop d !low-order bytes of number to be shifted @@ -42,9 +39,6 @@ 3: push h push d - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/sri4.s b/mach/i80/libem/sri4.s index e6edd589a..13d8f9620 100644 --- a/mach/i80/libem/sri4.s +++ b/mach/i80/libem/sri4.s @@ -14,9 +14,6 @@ .sri4: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg pop b !number of shifts pop d !low-order bytes of number to be shifted @@ -59,8 +56,5 @@ 4: push h push d - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/libem/sti.s b/mach/i80/libem/sti.s index bdaead579..13a25f841 100644 --- a/mach/i80/libem/sti.s +++ b/mach/i80/libem/sti.s @@ -11,9 +11,6 @@ .sti: pop h shld .retadr - mov l,c - mov h,b - shld .bcreg ! save bc pop h xra a @@ -43,9 +40,7 @@ ora e jnz 1b -2: lhld .bcreg - mov c,l - mov b,h +2: lhld .retadr pchl diff --git a/mach/i80/libem/xor.s b/mach/i80/libem/xor.s index 011e59078..fb32e36bc 100644 --- a/mach/i80/libem/xor.s +++ b/mach/i80/libem/xor.s @@ -13,9 +13,6 @@ .xor: pop h shld .retadr - mov h,b - mov l,c - shld .bcreg lxi h,0 dad sp @@ -36,8 +33,5 @@ pop h sphl - lhld .bcreg - mov b,h - mov c,l lhld .retadr pchl diff --git a/mach/i80/ncg/table b/mach/i80/ncg/table index 405a7bfac..b28e8f475 100644 --- a/mach/i80/ncg/table +++ b/mach/i80/ncg/table @@ -6,7 +6,6 @@ /************************************************************/ /************************************************************/ - rcsid = "$Id$" EM_WSIZE = 2 @@ -22,6 +21,7 @@ lbreg /* the registers used as localbase */ reg /* the free registers */ regpair /* register pairs bc, de and hl */ regind /* register indirect */ +bcreg /* bc-register-pair */ dereg /* de-register-pair */ hlreg /* hl-register-pair */ hl_or_de /* de- or hl-register-pair */ @@ -35,7 +35,7 @@ REGISTERS a :areg,reg. b,c :lbreg. d,e,h,l :reg. -lb("b")=b+c :regpair, localbase, regind. +bc("b")=b+c :regpair, regind, bcreg. de("d")=d+e :regpair, regind, dereg, hl_or_de. hl("h")=h+l :regpair, hlreg, hl_or_de. sp :stackpointer. @@ -49,6 +49,7 @@ const2 = { INT num; } 2 num. smallconst2 = { INT num; } 2 num. label = { ADDR off; } 2 off. m = { } 2 cost(0,3) "m". +fp = { } 2. SETS @@ -171,6 +172,10 @@ from regpair to regpair gen mov %2.1,%1.1 mov %2.2,%1.2 +from fp to hlreg + gen + lhld {label, ".fp"} + TESTS to test areg /* dummy test, never used */ @@ -262,13 +267,13 @@ pat ldc #endif pat lol - uses hlreg={const2, $1}, dereg - gen - dad lb - mov e,{m} - inx hl - mov d,{m} - yields de + uses hlreg={fp}, regpair={const2, $1} + gen + dad %b + mov %b.2, {m} + inx hl + mov %b.1, {m} + yields %b pat loe uses hlreg @@ -296,16 +301,17 @@ pat lof #endif pat lal - uses hlreg={const2,$1} + uses hlreg={fp}, regpair={const2,$1} gen - dad lb + dad %b yields hl pat lae yields {label,$1} pat lxl $1==0 - yields lb + uses hlreg={fp} + yields hl pat lxl $1==1 leaving @@ -313,47 +319,51 @@ pat lxl $1==1 loi 2 pat lxl $1>1 && $1<256 -uses dereg, areg={const1,$1}, hlreg -gen move lb,de - 1: - lxi hl,{const2,SL} - dad de - mov e,{m} - inx hl - mov d,{m} - dcr a - jnz {label,1b} yields de + uses dereg, areg={const1,$1}, hlreg={fp} + gen + xchg. + 1: + lxi hl,{const2,SL} + dad de + mov e,{m} + inx hl + mov d,{m} + dcr a + jnz {label,1b} + yields de pat lxa $1==0 - uses hlreg + uses hlreg={fp}, regpair={const2, SL} gen - move {const2,SL},hl - dad lb + dad %b yields hl pat lxa $1==1 -uses dereg, hlreg -gen move {const2,SL},hl - dad lb - mov e,{m} - inx hl - mov d,{m} - lxi hl,{const2,SL} - dad de yields hl + uses dereg={const2, SL}, hlreg={fp} + gen + dad de + mov e,{m} + inx hl + mov d,{m} + 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 - mov e,{m} - inx hl - mov d,{m} - dcr a - jnz {label,1b} - lxi hl,{const2,SL} - dad de yields hl + uses dereg, hlreg={fp}, areg={const1,$1} + gen + xchg. + 1: + lxi hl,{const2,SL} + dad de + mov e,{m} + inx hl + mov d,{m} + dcr a + jnz {label,1b} + lxi hl,{const2,SL} + dad de + yields hl pat loi $1==1 with exact label @@ -396,18 +406,19 @@ with hlreg mov l,a yields hl de pat loi $1<=510 -with hl_or_de STACK -uses hl_or_de={const2,$1-1}, areg -gen dad de - mvi a,{const1,$1/2} - 1: - mov d,{m} - dcx hl - mov e,{m} - dcx hl - push de - dcr a - jnz {label,1b} + with hl_or_de STACK + uses hl_or_de={const2,$1-1}, areg + gen + dad de + mvi a,{const1,$1/2} + 1: + mov d,{m} + dcx hl + mov e,{m} + dcx hl + push de + dcr a + jnz {label,1b} pat loi $1>=512 kills ALL @@ -458,21 +469,21 @@ with dereg yields de de leaving stl $1 #ifdef USE_I80_RSTS pat stl sfit($1, 8) - with dereg - uses hlreg, areg + with bcreg + uses hlreg, dereg, areg gen rst {const1, 2} data1 {const1, $1} #endif pat stl - with dereg - uses hlreg={const2, $1} + with regpair + uses hlreg={fp}, regpair={const2, $1} gen - dad lb - mov {m}, e + dad %b + mov {m}, %1.2 inx hl - mov {m}, d + mov {m}, %1.1 pat ste loe $1==$2 with hlreg yields hl hl leaving ste $1 @@ -908,7 +919,7 @@ pat inc #ifdef USE_I80_RSTS pat inl sfit($1, 8) - uses hlreg, areg + uses hlreg, dereg, areg gen rst {const1, 3} data1 {const1, $1} @@ -920,9 +931,9 @@ pat inc #endif pat inl - uses hlreg={const2,$1} + uses hlreg={fp}, regpair={const2, $1} gen - dad lb + dad %b inr {m} jnz {label,1f} inx hl @@ -957,15 +968,16 @@ gen dcx %1 yields %1 #endif pat del - uses hlreg={const2,$1}, dereg - gen dad lb - mov e,{m} + uses hlreg={fp}, regpair={const2,$1} + gen + dad %b + mov %b.2, {m} inx hl - mov d,{m} - dcx de - mov {m},d + mov %b.1, {m} + dcx %b + mov {m}, %b.1 dcx hl - mov {m},e + mov {m}, %b.2 pat dee uses hlreg @@ -975,7 +987,7 @@ gen lhld {label,$1} #ifdef USE_I80_RSTS pat zrl sfit($1, 8) - uses hlreg, areg + uses hlreg, dereg, areg gen rst {const1, 3} data1 {const1, $1} @@ -986,9 +998,9 @@ gen lhld {label,$1} #endif pat zrl - uses hlreg={const2,$1}, areg + uses hlreg={fp}, regpair={const2,$1}, areg gen - dad lb + dad %b xra a mov {m},a inx hl @@ -2049,7 +2061,7 @@ gen xra a #ifdef USE_I80_RSTS pat lol zeq sfit($1, 8) with STACK - uses hlreg, areg + uses hlreg, dereg, areg gen rst {const1, 3} data1 {const1, $1} @@ -2061,9 +2073,9 @@ gen xra a pat lol zeq with STACK - uses hlreg={const2,$1}, areg + uses hlreg={fp}, regpair={const2,$1}, areg gen - dad lb + dad %b mov a,{m} inx hl ora {m} @@ -2072,7 +2084,7 @@ pat lol zeq #ifdef USE_I80_RSTS pat lol zne sfit($1, 8) with STACK - uses hlreg, areg + uses hlreg, dereg, areg gen rst {const1, 3} data1 {const1, $1} @@ -2084,13 +2096,13 @@ pat lol zeq pat lol zne with STACK - uses hlreg={const2,$1}, areg - gen - dad lb - mov a,{m} - inx hl - ora {m} - jnz {label,$2} + uses hlreg={fp}, regpair={const2,$1}, areg + gen + dad %b + mov a,{m} + inx hl + ora {m} + jnz {label,$2} pat ior zeq $1==2 with hl_or_de hl_or_de STACK @@ -2244,13 +2256,14 @@ uses hlreg={label,$1} gen shld {label,"hol0"+4} pat gto -with STACK -gen lhld {label,$1+2} - sphl. - lhld {label,$1+4} - move hl,lb - lhld {label,$1} - pchl. + with STACK + gen + lhld {label, $1+4} + shld {label, ".fp"} + lhld {label, $1+2} + sphl. + lhld {label, $1} + pchl. pat lim uses hlreg @@ -2266,7 +2279,9 @@ gen lhld {label,"hol0"} inx hl shld {label,"hol0"} -pat lor $1==0 yields lb +pat lor $1==0 + uses hlreg={fp} + yields hl pat lor $1==1 with STACK @@ -2311,7 +2326,9 @@ with hlreg gen shld {label,".ignmask"} pat str $1==0 -with localbase + with hlreg + gen + shld {label, ".fp"} pat str $1==1 with hlreg diff --git a/plat/cpm/boot.s b/plat/cpm/boot.s index 40ab0d775..5aa45a929 100644 --- a/plat/cpm/boot.s +++ b/plat/cpm/boot.s @@ -156,6 +156,7 @@ envp: .space 2 ! envp array (always empty, must be after argv) .define .trapproc, .retadr, .retadr1 .define .bcreg, .areg .define .tmp1, .fra, block1, block2, block3 +.define .fp .comm .trapproc, 2 .comm .retadr, 2 ! used to save return address @@ -167,6 +168,7 @@ envp: .space 2 ! envp array (always empty, must be after argv) block1: .space 4 ! used by 32 bits divide and block2: .space 4 ! multiply routines block3: .space 4 ! must be contiguous (.comm doesn't guarantee this) +.comm .fp, 2 .sect .rom progname: .asciz 'ACKCPM' -- 2.34.1