Further C compiler syntax changes, use .dw/.ds, replace the old .comm directive
authorNick Downing <nick@ndcode.org>
Thu, 11 Aug 2022 04:55:17 +0000 (14:55 +1000)
committerNick Downing <nick@ndcode.org>
Thu, 11 Aug 2022 05:05:43 +0000 (15:05 +1000)
usr/src/cmd/c/c11.c
usr/src/libc/a.sh

index ef34883..d385390 100644 (file)
@@ -5,6 +5,9 @@
 
 #include "c1.h"
 
+/* needed for restoring the area after common definition in asxxxx syntax */
+static char *area = "text";
+
 max(a, b)
 {
        if (a>b)
@@ -799,7 +802,7 @@ getree()
 #if TRACE_IR
  fprintf(stderr, "SINIT\n");
 #endif
-               printf("%d\n", geti());
+               printf(".dw     %d\n", geti());
                break;
 
        case EOFC:
@@ -813,7 +816,7 @@ getree()
  fprintf(stderr, "BDATA\n");
 #endif
                if (geti() == 1) {
-                       printf(".db ");
+                       printf(".db     ");
                        for (;;)  {
                                printf("%d", geti());
                                if (geti() != 1)
@@ -829,6 +832,7 @@ getree()
  fprintf(stderr, "PROG\n");
 #endif
                printf(".area   text\n");
+               area = "text";
                break;
 
        case DATA:
@@ -836,6 +840,7 @@ getree()
  fprintf(stderr, "DATA\n");
 #endif
                printf(".area   data\n");
+               area = "data";
                break;
 
        case BSS:
@@ -843,6 +848,7 @@ getree()
  fprintf(stderr, "BSS\n");
 #endif
                printf(".area   bss\n");
+               area = "bss";
                break;
 
        case SYMDEF:
@@ -867,14 +873,14 @@ getree()
  fprintf(stderr, "CSPACE\n");
 #endif
                t = outname(s);
-               printf(".comm   %.8s,%d\n", t, geti());
+               printf(".area   _%.8s (rel,ovr)\n%.8s:.ds       %d\n.area       %s\n", t, t, geti(), area);
                break;
 
        case SSPACE:
 #if TRACE_IR
  fprintf(stderr, "SSPACE\n");
 #endif
-               printf(".=.+%d\n", (t=geti()));
+               printf(".ds     %d\n", (t=geti()));
                totspace += (unsigned)t;
                break;
 
@@ -909,7 +915,7 @@ getree()
 #endif
                t = geti();
                printf("mov     #L%d,r0\n.globl mcount\njsr     pc,mcount\n", t);
-               printf(".area   bss\nL%d:.=.+2\n.area   text\n", t);
+               printf(".area   bss\nL%d:.ds    2\n.area        text\n", t);
                break;
 
        case SNAME:
@@ -1190,7 +1196,7 @@ struct fasgn *atp;
                if (tp->op==RFORCE) {   /* function return */
                        if (sfuncr.nloc==0) {
                                sfuncr.nloc = isn++;
-                               printf(".area   bss\nL%d:.=.+%d\n.area  text\n", sfuncr.nloc, nwords*sizeof(int));
+                               printf(".area   bss\nL%d:.ds    %d\n.area       text\n", sfuncr.nloc, nwords*sizeof(int));
                        }
                        atp->tr1 = tnode(ASSIGN, STRUCT, &sfuncr, tp->tr1);
                        strasg(atp);
index 724b2af..1fee370 100755 (executable)
@@ -2,4 +2,4 @@
 mkdir --parents ../../../tmp
 export APOUT_ROOT=`pwd`/../../..
 export PATH=`pwd`/../../../bin:`pwd`
-cc -S -O /usr/src/libc/stdio/doscan.c
+cc -S -O /usr/src/libc/gen/nlist.c