Implement fr0-5 (requires changes to table and new table substitutions)
authorNick Downing <nick@ndcode.org>
Thu, 11 Aug 2022 05:56:03 +0000 (15:56 +1000)
committerNick Downing <nick@ndcode.org>
Thu, 11 Aug 2022 07:00:15 +0000 (17:00 +1000)
usr/src/cmd/c.sh
usr/src/cmd/c/c10.c
usr/src/cmd/c/cvopt.c
usr/src/cmd/c/table.s
usr/src/libc/a.sh

index d4bec15..435eb3c 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-git checkout ../../../bin/as ../../../lib/c[012]
+git checkout ../../../bin/as ../../../lib/c[012] c/cvopt
 if ! test -d ../../../tmp
 then
   ln -s /tmp ../../../tmp
@@ -7,5 +7,6 @@ fi
 export APOUT_ROOT=`pwd`/../../..
 export PATH=`pwd`/../../../bin:`pwd`
 cc -n -s -O as.c -o as
+rm -f c/cvopt
 (echo ==== c =====; cd c; make cp)
 mv as ../../../bin
index 97752d4..1f6a155 100644 (file)
@@ -361,12 +361,12 @@ again:
                                        printf("mov\tr%d,-(sp)\n",r+1);
                                        nstack++;
                                }
-                               printf("mov%c   r%d,%c(sp)\n", modf, r,
+                               printf("mov%c   %cr%d,%c(sp)\n", modf, modf, r,
                                        table==sptab? '-':0);
                                nstack++;
                        }
                        if (table==cctab)
-                               printf("tst%c   r%d\n", modf, r);
+                               printf("tst%c   %cr%d\n", modf, modf, r);
                        return(r);
                }
        }
@@ -560,6 +560,14 @@ loop:
                prins(tree->op, c, instab);
                goto loop;
 
+       /* BF1 (like B1 but only for floats not bytes) */
+       case 'Q':
+               if ((opd&LEAF) != 0)
+                       p = tree;
+               else
+                       p = p1;
+               goto pb1;
+
        /* B1 */
        case 'C':
                if ((opd&LEAF) != 0)
@@ -573,6 +581,11 @@ loop:
                p = tree;
                goto pb1;
 
+       /* BF2 (like B2 but only for floats not bytes) */
+       case 'R':
+               p = p2;
+               goto pb1;
+
        /* B2 */
        case 'D':
                p = p2;
@@ -1189,6 +1202,7 @@ movreg(r0, r1, tree)
 struct tnode *tree;
 {
        register char *s;
+       int modf;
 
        if (r0==r1)
                return;
@@ -1200,5 +1214,6 @@ struct tnode *tree;
                        printf(s, r0,r1,r0+1,r1+1);
                return;
        }
-       printf("mov%c   r%d,r%d\n", isfloat(tree), r0, r1);
+       modf = isfloat(tree);
+       printf("mov%c   %cr%d,%cr%d\n", modf, modf, r0, modf, r1);
 }
index 6592641..8ba24fc 100644 (file)
@@ -16,6 +16,8 @@ char **argv;
        B2    D
        BE    L
        BF    P
+       BF1   Q
+       BF2   R
        C1    E
        C2    F
        F     G
@@ -112,7 +114,19 @@ loop:
                        goto loop;
 
                case 'F':
-                       put('P');
+                       c = getchar();
+                       switch (c) {
+                       case '1':
+                               put('Q');
+                               break;
+                       case '2':
+                               put('R');
+                               break;
+                       default:
+                               put('P');
+                               ungetc(c, stdin);
+                               break;
+                       }
                        goto loop;
                }
                put('?');
index a49dac3..f668789 100644 (file)
@@ -87,23 +87,23 @@ cr106:
        clr     R
 
 %zf,n
-       clrf    R
+       clrf    fR
 
 %a,n
 %ad,n
-       movB1   A1,R
+       movB1   A1,BF1R
 
 %af,n
-       movof   A1,R
+       movof   A1,fR
 
 %n*,n
 %nd*,n
        F*
-       movB1   #1(R),R
+       movB1   #1(R),BF1R
 
 %nf*,n
        F*
-       movof   #1(R),R
+       movof   #1(R),fR
 
 %al,n
        mov     A1+,R+
@@ -120,7 +120,7 @@ cr106:
 / ++,-- postfix
 cr32:
 %a,1
-       movB1   A1',R
+       movB1   A1',BF1R
        I'B1    A1''
 
 %aw,n
@@ -129,7 +129,7 @@ cr32:
 
 %e*,1
        F1*
-       movB1   #1(R1),R
+       movB1   #1(R1),BF1R
        I'B1    #1(R1)
 
 %n*,1
@@ -175,7 +175,7 @@ cr37:
 %n,n
 %nf,n
        F
-       IBF     R
+       IBF     BFR
 
 %nl,n
        F
@@ -188,53 +188,53 @@ cr80:
 %a,n
 %ad,nf
        S
-       movB1   R,A1
+       movB1   BF1R,A1
 
 %af,nf
        S
-       movfo   R,A1
+       movfo   fR,A1
 
 %nd*,af
        F*
        S
-       movf    R,#1(R)
+       movf    fR,#1(R)
 
 %n*,aw
        F*
        movB1   A2,#1(R)
-       movB1   #1(R),R
+       movB1   #1(R),BF1R
 
 %nf*,af
        F*
        S
-       movfo   R,#1(R)
+       movfo   fR,#1(R)
 
 %n*,e
        F*
        S1
        movB1   R1,#1(R)
-       movB1   R1,R
+       movB1   BF1R1,BF1R
 
 %ed*,nf
        S
        F1*
-       movf    R,#1(R1)
+       movf    fR,#1(R1)
 
 %ef*,nf
        S
        F1*
-       movfo   R,#1(R1)
+       movfo   fR,#1(R1)
 
 %n*,n
 %nd*,nf
        FS*
        S
-       movB1   R,*(sp)+
+       movB1   BF1R,*(sp)+
 
 %nf*,nf
        FS*
        S
-       movfo   R,*(sp)+
+       movfo   fR,*(sp)+
 
 %al,nl
        S
@@ -284,35 +284,35 @@ cr40:
 %n,aw
 %nf,ad
        F
-       IB2     A2,R
+       IB2     A2,BF2R
 
 %[add2:]
 %n,ew*
 %nf,ed*
        F
        S1*
-       IB2     #2(R1),R
+       IB2     #2(R1),BF2R
 
 %[add3:]
 %n,e
 %nf,ef
        F
        S1
-       IBF     R1,R
+       IBF     BFR1,BFR
 
 %[add4:]
 %n,nw*
 %nf,nd*
        SS*
        F
-       IB2     *(sp)+,R
+       IB2     *(sp)+,BF2R
 
 %[add5:]
 %n,n
 %nf,nf
        SS
        F
-       IBF     (sp)+,R
+       IBF     (sp)+,BFR
 
 %nl,c
 %nl,au
@@ -441,9 +441,9 @@ cr70:
 %[addq1a:]
 %a,aw
 %ad,ad
-       movB1   A1',R
-       IBF     A2,R
-       movB1   R,A1''
+       movB1   A1',BF1R
+       IBF     A2,BFR
+       movB1   BF1R,A1''
 
 %[addq2:]
 %aw,nw*
@@ -466,25 +466,25 @@ cr70:
 
 %[addq4a:]
 %ad,ef
-       movf    A1',R
+       movf    A1',fR
        S1
-       IBF     R1,R
-       movf    R,A1''
+       IBF     BFR1,BFR
+       movf    fR,A1''
 
 %[addq5:]
 %a,n
 %ad,nf
        SS
-       movB1   A1',R
-       IBF     (sp)+,R
-       movB1   R,A1''
+       movB1   A1',BF1R
+       IBF     (sp)+,BFR
+       movB1   BF1R,A1''
 
 %[addq6:]
 %af,nf
        SS
-       movof   A1',R
-       IBF     (sp)+,R
-       movfo   R,A1''
+       movof   A1',fR
+       IBF     (sp)+,BFR
+       movfo   fR,A1''
 
 %[addq7:]
 %ew*,n
@@ -504,26 +504,26 @@ cr70:
 %n*,n
        FS*
        SS
-       movB1   *2(sp),R
-       IBF     (sp)+,R
-       movB1   R,*(sp)+
+       movB1   *2(sp),BF1R
+       IBF     (sp)+,BFR
+       movB1   BF1R,*(sp)+
 
 %[addq9a:]
 %nd*,nf
        SS
        F*
-       movB1   #1(R),R
-       IBF     (sp)+,R
-       movB1   R,#1(R)
+       movB1   #1(R),BF1R
+       IBF     (sp)+,BFR
+       movB1   BF1R,#1(R)
 
 %[addq10:]
 %nf*,nf
        SS
        F*
-       movof   #1(R),R1
-       IBF     (sp)+,R1
-       movfo   R1,#1(R)
-       movf    R1,R
+       movof   #1(R),fR1
+       IBF     (sp)+,BFR1
+       movfo   fR1,#1(R)
+       movf    fR1,fR
 
 %al,c
        I       A2,A1+
@@ -595,33 +595,33 @@ cr72:
 / =/ ;  R must be odd on integers
 cr73:
 %a,aw
-       movB1   A1',R
+       movB1   A1',BF1R
        V       R-
-       IBF     A2,R-
-       movB1   R-,A1''
+       IBF     A2,BFR-
+       movB1   BF1R-,A1''
 
 %a,n
        SS
-       movB1   A1',R
+       movB1   A1',BF1R
        V       R-
        I       (sp)+,R-
-       movB1   R-,A1''
+       movB1   BF1R-,A1''
 
 %e*,n
        SS
        F1*
-       movB1   #1(R1),R
+       movB1   #1(R1),BF1R
        V       R-
        I       (sp)+,R-
-       movB1   R-,#1(R1)
+       movB1   BF1R-,#1(R1)
 
 %n*,n
        FS*
        SS
-       movB1   *2(sp),R
+       movB1   *2(sp),BF1R
        V       R-
        I       (sp)+,R-
-       movB1   R-,*(sp)+
+       movB1   BF1R-,*(sp)+
 
 %ad,ad
 %      [addq1a]
@@ -644,30 +644,30 @@ cr73:
 / =mod; R must be odd on integers
 cr74:
 %a,aw
-       movB1   A1',R
+       movB1   A1',BF1R
        V       R-
        I       A2,R-
-       movB1   R,A1''
+       movB1   BF1R,A1''
 
 %a,n
        SS
-       movB1   A1',R
+       movB1   A1',BF1R
        V       R-
        I       (sp)+,R-
-       movB1   R,A1''
+       movB1   BF1R,A1''
 
 %e*,n
        SS
        F1*
-       movB1   #1(R1),R
+       movB1   #1(R1),BF1R
        V       R-
        I       (sp)+,R-
-       movB1   R,#1(R1)
+       movB1   BF1R,#1(R1)
 
 %n*,n
        FS*
        SS
-       movB1   *2(sp),R
+       movB1   *2(sp),BF1R
        V       R-
        I       (sp)+,R-
        mov     R,*(sp)+
@@ -689,8 +689,8 @@ cr79:
        movB1   *(sp),-(sp)
        S
        xor     R,(sp)
-       movB1   (sp)+,R
-       movB1   R,*(sp)+
+       movB1   (sp)+,BF1R
+       movB1   BF1R,*(sp)+
 
 / =>> (all complicated cases done by =<< -)
 cr75:
@@ -723,28 +723,28 @@ cr91:
 / int -> float
 cr51:
 %aw,n
-       movif   A1,R
+       movif   A1,fR
 
 %nw*,n
        F*
-       movif   #1(R),R
+       movif   #1(R),fR
 
 %n,n
        F
-       movif   R,R
+       movif   R,fR
 
 / float, double -> int
 cr52:
 %nf,n
        F
-       movfi   R,R
+       movfi   fR,R
 
 / double (float) to long
 cr56:
 %nf,n
        F
        setl
-       movfi   R,-(sp)
+       movfi   fR,-(sp)
        mov     (sp)+,R
        mov     (sp)+,R+
        seti
@@ -753,19 +753,19 @@ cr56:
 cr57:
 %al,n
        setl
-       movif   A1,R
+       movif   A1,fR
        seti
 
 %nl*,n
        F*
        setl
-       movif   #1(R),R
+       movif   #1(R),fR
        seti
 
 %nl,n
        FS
        setl
-       movif   (sp)+,R
+       movif   (sp)+,fR
        seti
 
 / integer to long
@@ -875,7 +875,7 @@ ci80:
 %[move5:]
 %a,n
        S
-       IB1     R,A1
+       IB1     BF1R,A1
 
 %[move6:]
 %n*,aw
@@ -894,7 +894,7 @@ ci80:
 %n*,e
        F*
        S1
-       IB1     R1,#1(R)
+       IB1     BF1R1,#1(R)
 
 %[move9:]
 %e*,nw*
@@ -907,7 +907,7 @@ ci80:
 %e*,n
        S
        F1*
-       IB1     R,#1(R1)
+       IB1     BF1R,#1(R1)
 
 %[move11:]
 %n*,nw*
@@ -920,16 +920,16 @@ ci80:
 %n*,n
        FS*
        S
-       IB1     R,*(sp)+
+       IB1     BF1R,*(sp)+
 
 %aw,nf
        S
-       movfi   R,A1
+       movfi   fR,A1
 
 %ew*,nf
        S
        F1*
-       movfi   R,#1(R1)
+       movfi   fR,#1(R1)
 
 %al,z
        clr     A1
@@ -958,14 +958,14 @@ ci80:
 %al,nf
        S
        setl
-       movfi   R,A1
+       movfi   fR,A1
        seti
 
 %el*,nf
        S
        F1*
        setl
-       movfi   R,#1(R1)
+       movfi   fR,#1(R1)
        seti
 
 %[move13:]
@@ -1122,15 +1122,15 @@ ci70:
 
 %a,nw*
        S*
-       movB1   A1',R1
+       movB1   A1',BF1R1
        I       #2(R),R1
-       movB1   R1,A1''
+       movB1   BF1R1,A1''
 
 %a,n
        S
-       movB1   A1',R1
+       movB1   A1',BF1R1
        I       R,R1
-       movB1   R1,A1''
+       movB1   BF1R1,A1''
 
 %ew*,n
 %      [move10]
@@ -1141,9 +1141,9 @@ ci70:
 %n*,n
        SS
        F*
-       movB1   #1(R),R1
+       movB1   #1(R),BF1R1
        I       (sp)+,R1
-       movB1   R1,#1(R)
+       movB1   BF1R1,#1(R)
 
 %al,c
 %al,au
@@ -1305,7 +1305,7 @@ cc60:
 %      [move1]
 
 %af,z
-       movof   A1,R
+       movof   A1,fR
 
 %n*,z
 %nd*,zf
@@ -1313,7 +1313,7 @@ cc60:
 
 %nf*,z
        F*
-       movof   #1(R),R
+       movof   #1(R),fR
 
 %n,z
 %nf,zf
@@ -1587,7 +1587,7 @@ cs56:
 %nf,n
        F
        setl
-       movfi   R,-(sp)
+       movfi   fR,-(sp)
        seti
 
 / setup for structure assign
index 1fee370..d8b5ab2 100755 (executable)
@@ -2,4 +2,4 @@
 mkdir --parents ../../../tmp
 export APOUT_ROOT=`pwd`/../../..
 export PATH=`pwd`/../../../bin:`pwd`
-cc -S -O /usr/src/libc/gen/nlist.c
+cc -S -O /usr/src/libc/gen/atof.c