Rework the code generator not to use BC for the frame pointer. Star Trek is up
authorDavid Given <dg@cowlark.com>
Tue, 12 Feb 2019 22:49:54 +0000 (23:49 +0100)
committerDavid Given <dg@cowlark.com>
Tue, 12 Feb 2019 22:49:54 +0000 (23:49 +0100)
from 40243 to 40539 bytes.

32 files changed:
mach/i80/libem/aar2.s
mach/i80/libem/and.s
mach/i80/libem/blm.s
mach/i80/libem/cii.s
mach/i80/libem/cmi4.s
mach/i80/libem/csa.s
mach/i80/libem/csb.s
mach/i80/libem/dup.s
mach/i80/libem/dvi2.s
mach/i80/libem/dvi4.s
mach/i80/libem/exg.s
mach/i80/libem/inn.s
mach/i80/libem/ior.s
mach/i80/libem/lar2.s
mach/i80/libem/loi.s
mach/i80/libem/mli4.s
mach/i80/libem/mlu2.s
mach/i80/libem/pro.s
mach/i80/libem/rck.s
mach/i80/libem/ret.s
mach/i80/libem/rol4.s
mach/i80/libem/ror4.s
mach/i80/libem/rst.s
mach/i80/libem/sar2.s
mach/i80/libem/sbi4.s
mach/i80/libem/set.s
mach/i80/libem/sli4.s
mach/i80/libem/sri4.s
mach/i80/libem/sti.s
mach/i80/libem/xor.s
mach/i80/ncg/table
plat/cpm/boot.s

index 0453fa0..6da75ec 100644 (file)
@@ -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
index 59a0253..1d0fc5e 100644 (file)
@@ -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
index 0ff5b91..5672fce 100644 (file)
@@ -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
 
index bf4e7ef..9b34205 100644 (file)
@@ -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
index 84c7c7d..fe9d62c 100644 (file)
@@ -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
index 9470481..91458e9 100644 (file)
@@ -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
        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!!!!
 
index 7813c8b..4da4a87 100644 (file)
@@ -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
index 50e0cc8..d35efd5 100644 (file)
@@ -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
index 7498d98..3129c2a 100644 (file)
@@ -19,9 +19,6 @@
 
 .dvi2: pop h
        shld .retadr
-       mov h,b
-       mov l,c
-       shld .bcreg
 
        sta .areg
        pop b           ! bc = divisor
 7:     mov d,h         ! return remainder
        mov e,l
 
-8:     lhld .bcreg
-       mov b,h
-       mov c,l
-       lhld .retadr
+8:     lhld .retadr
        pchl
index a25806d..407908d 100644 (file)
@@ -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
 
index 8a345b0..c5cfbf5 100644 (file)
@@ -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
index c39b875..fa5a091 100644 (file)
@@ -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
 
index cd7793b..2746b41 100644 (file)
@@ -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
index 82658ff..82a18bc 100644 (file)
@@ -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
index 6eebb87..15104b1 100644 (file)
@@ -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
index eab29dd..a33ab7c 100644 (file)
@@ -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
index 4f4b700..498485a 100644 (file)
@@ -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
index 0c5fa3f..19e46dd 100644 (file)
@@ -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
        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
 
index d7c85c9..4207634 100644 (file)
@@ -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
index 8c08e97..131276f 100644 (file)
@@ -6,9 +6,9 @@
 
 .define .ret
 .ret:
-       mov h, b
-       mov l, c
+       lhld .fp
        sphl
-       pop b
+       pop h
+       shld .fp
        ret
 
index 41219ea..607c161 100644 (file)
@@ -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
index 490c75a..c77665f 100644 (file)
@@ -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
index a5234bd..bedb9b5 100644 (file)
     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
 
index 6e1694e..7ffc1fb 100644 (file)
@@ -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
index 7cf0e9c..895baa0 100644 (file)
@@ -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
index 3f47829..e2f7a3e 100644 (file)
@@ -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
index b791aae..523b0bb 100644 (file)
@@ -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
 
index e6edd58..13d8f96 100644 (file)
@@ -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
index bdaead5..13a25f8 100644 (file)
@@ -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
 
index 011e590..fb32e36 100644 (file)
@@ -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
index 405a7bf..b28e8f4 100644 (file)
@@ -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
index 40ab0d7..5aa45a9 100644 (file)
@@ -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'