Add yywarning
[unix-history] / usr / src / old / as.vax / asparse.c
index d8a8a96..95ec161 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 1980 Regents of the University of California */
 /* Copyright (c) 1980 Regents of the University of California */
-static char sccsid[] = "@(#)asparse.c 4.5 %G%";
+static char sccsid[] = "@(#)asparse.c 4.7 %G%";
 #include <stdio.h>
 #include "as.h"
 #include "asexpr.h"
 #include <stdio.h>
 #include "as.h"
 #include "asexpr.h"
@@ -78,6 +78,7 @@ int   yyparse()
                        int             field_value;    /*the value to stuff in a field*/
                        char            *stabname;      /*name of stab dealing with*/
                        ptrall          stabstart;      /*where the stab starts in the buffer*/
                        int             field_value;    /*the value to stuff in a field*/
                        char            *stabname;      /*name of stab dealing with*/
                        ptrall          stabstart;      /*where the stab starts in the buffer*/
+                       int             reloc_how;      /* how to relocate expressions */
 
        xp = explist;
        ap = arglist;
 
        xp = explist;
        ap = arglist;
@@ -364,18 +365,15 @@ restlab:
                 if ((locxp->e_xtype&XTYPE)!=XABS) {
                        if (bitoff)
                                yyerror("Illegal relocation in field");
                 if ((locxp->e_xtype&XTYPE)!=XABS) {
                        if (bitoff)
                                yyerror("Illegal relocation in field");
-                       field_width=LEN1;
-                       if (curlen==NBPW)
-                               field_width = LEN4;
-                       if (curlen==NBPW/2)
-                               field_width = LEN2;
+                       switch(curlen){
+                               case NBPW/4:    reloc_how = TYPB; break;
+                               case NBPW/2:    reloc_how = TYPW; break;
+                               case NBPW:      reloc_how = TYPL; break;
+                       }
                        if (passno == 1){
                        if (passno == 1){
-                               dotp->e_xvalue += reflen[field_width];
+                               dotp->e_xvalue += ty_nbyte[reloc_how];
                        } else {
                        } else {
-                               outrel(&locxp->e_xvalue,
-                                       field_width,
-                                       locxp->e_xtype,
-                                       locxp->e_xname);
+                               outrel(locxp, reloc_how);
                        }
                } else {
                        field_value = locxp->e_xvalue & ( (1L << field_width)-1);
                        }
                } else {
                        field_value = locxp->e_xvalue & ( (1L << field_width)-1);
@@ -548,7 +546,7 @@ restlab:
  *             final expression is taken to be  the current
  *             location counter, and is patched by the 2nd pass
  *
  *             final expression is taken to be  the current
  *             location counter, and is patched by the 2nd pass
  *
- *     .stab{<expr>,}*8,<expr>, <expr>, <expr>, <expr>
+ *     .stab{<expr>,}*NCPS,<expr>, <expr>, <expr>, <expr>
  *     .stabn           <expr>, <expr>, <expr>, <expr>
  *     .stabs   STRING, <expr>, <expr>, <expr>, <expr>
  *     .stabd           <expr>, <expr>, <expr> # . 
  *     .stabn           <expr>, <expr>, <expr>, <expr>
  *     .stabs   STRING, <expr>, <expr>, <expr>, <expr>
  *     .stabd           <expr>, <expr>, <expr> # . 
@@ -567,7 +565,7 @@ restlab:
        (char *)stabstart -= sizeof(struct symtab *);
        (char *)stabstart -= sizeof(toktype);
        shift;
        (char *)stabstart -= sizeof(struct symtab *);
        (char *)stabstart -= sizeof(toktype);
        shift;
-       for (argcnt = 0; argcnt < 8; argcnt++){
+       for (argcnt = 0; argcnt < NCPS; argcnt++){
                expr(locxp, val);
                stpt->s_name[argcnt] = locxp->e_xvalue;
                xp = explist;
                expr(locxp, val);
                stpt->s_name[argcnt] = locxp->e_xvalue;
                xp = explist;
@@ -1047,3 +1045,19 @@ yyerror(s, a1, a2,a3,a4,a5)
        fprintf(sink, s, a1, a2,a3,a4,a5);
        fprintf(sink, "\n");
 }
        fprintf(sink, s, a1, a2,a3,a4,a5);
        fprintf(sink, "\n");
 }
+
+/*VARARGS1*/
+yywarning(s, a1, a2,a3,a4,a5)
+       char    *s;
+{
+
+#define        sink stdout
+
+       if (anyerrs == 0 && ! silent) 
+               fprintf(sink, "Assembler:\n");
+       if (silent) return;
+       
+       fprintf(sink, "\"%s\", line %d: WARNING: ", dotsname, lineno);
+       fprintf(sink, s, a1, a2,a3,a4,a5);
+       fprintf(sink, "\n");
+}