handle enums w/o tags as structure/union members
[unix-history] / usr / src / old / as.vax / asjxxx.c
index 36ced59..ec62d37 100644 (file)
@@ -1,5 +1,10 @@
-/* Copyright (c) 1980 Regents of the University of California */
-static char sccsid[] = "@(#)asjxxx.c 4.5 %G%";
+/*
+ *     Copyright (c) 1982 Regents of the University of California
+ */
+#ifndef lint
+static char sccsid[] = "@(#)asjxxx.c 4.8 %G%";
+#endif not lint
+
 #include       <stdio.h>
 #include       "as.h"
 #include       "assyms.h"
 #include       <stdio.h>
 #include       "as.h"
 #include       "assyms.h"
@@ -42,8 +47,10 @@ initijxxx()
 /*
  *     Handle jxxx instructions
  */
 /*
  *     Handle jxxx instructions
  */
-ijxout(op,ap,nact)
-       struct arg *ap;
+ijxout(opcode, ap, nact)
+       struct  Opcode  opcode;
+       struct  arg     *ap;
+       int     nact;
 {
        if (passno == 1){
                /*
 {
        if (passno == 1){
                /*
@@ -56,11 +63,11 @@ ijxout(op,ap,nact)
                /*
                 *      We assume the MINIMAL length
                 */
                /*
                 *      We assume the MINIMAL length
                 */
-               putins(op,ap,nact); 
+               putins(opcode, ap, nact); 
                jumpfrom = lastjxxx;
                jumpfrom->s_tag = JXACTIVE;
                jumpfrom->s_jxbump = 0;
                jumpfrom = lastjxxx;
                jumpfrom->s_tag = JXACTIVE;
                jumpfrom->s_jxbump = 0;
-               if (op == JBR)
+               if (opcode.Op_popcode == JBR)
                        jumpfrom->s_jxfear = jbrfsize;
                else
                        jumpfrom->s_jxfear = jxxxfsize;
                        jumpfrom->s_jxfear = jbrfsize;
                else
                        jumpfrom->s_jxfear = jxxxfsize;
@@ -69,9 +76,13 @@ ijxout(op,ap,nact)
                jumpfrom->s_dest = lastnam;
                jumpfrom->s_type = dotp->e_xtype;       /*only TEXT or DATA*/
                jumpfrom->s_index = dotp-usedot;
                jumpfrom->s_dest = lastnam;
                jumpfrom->s_type = dotp->e_xtype;       /*only TEXT or DATA*/
                jumpfrom->s_index = dotp-usedot;
+#ifdef DEBUG
+               jumpfrom->s_name = ITABFETCH(opcode)->i_name;
+               jumpfrom->s_jxline = lineno;
+#endif
                /*
                 *      value ALWAYS (ALWAYS!!!) indexes the next instruction
                /*
                 *      value ALWAYS (ALWAYS!!!) indexes the next instruction
-                *      after the jump, even in the jump must be exploded
+                *      after the jump, even if the jump must be exploded
                 *      (bumped)
                 */
                jumpfrom->s_value = dotp->e_xvalue;
                 *      (bumped)
                 */
                jumpfrom->s_value = dotp->e_xvalue;
@@ -80,10 +91,11 @@ ijxout(op,ap,nact)
                /*
                 *      READ THIS AFTER LOOKING AT jxxxfix()
                 */
                /*
                 *      READ THIS AFTER LOOKING AT jxxxfix()
                 */
-               register long           oxvalue;
-               register struct exp     *xp; 
-               register struct symtab  *tunnel;
-               register struct arg     *aplast;
+               reg     long            oxvalue;
+               reg     struct  exp     *xp; 
+               reg     struct  symtab  *tunnel;
+               reg     struct  arg     *aplast;
+                       struct  Opcode  nopcode;
 
                aplast = ap + nact - 1;
                xp = aplast->a_xp;
 
                aplast = ap + nact - 1;
                xp = aplast->a_xp;
@@ -97,25 +109,35 @@ ijxout(op,ap,nact)
                                                        /*non bumped branch byteis only 2 back*/
                }
                if (lastjxxx->s_jxbump == 0){   /*wasn't bumped, so is short form*/
                                                        /*non bumped branch byteis only 2 back*/
                }
                if (lastjxxx->s_jxbump == 0){   /*wasn't bumped, so is short form*/
-                       putins(op, ap, nact);
+                       putins(opcode, ap, nact);
                } else {
                } else {
-                       if (op != JBR){ /*branch reverse conditional byte over 
-                                         branch unconditional word*/
+                       if (opcode.Op_popcode != JBR){
+                               /*
+                                *      branch reverse conditional byte over
+                                *      branch unconditional word
+                                */
                                oxvalue = xp->e_xvalue;
                                xp->e_xvalue = lastjxxx->s_value;
                                oxvalue = xp->e_xvalue;
                                xp->e_xvalue = lastjxxx->s_value;
-                               putins(op^1, ap, nact);
+                               nopcode = opcode;
+                               nopcode.Op_popcode ^= 1;
+                               putins(nopcode, ap, nact);
                                xp->e_xvalue = oxvalue;
                        }
                                xp->e_xvalue = oxvalue;
                        }
-                       putins(jxxxJUMP ? JMP : BRW, aplast, 1);
+                       nopcode.Op_eopcode = CORE;
+                       nopcode.Op_popcode = jxxxJUMP ? JMP : BRW;
+                       putins(nopcode, aplast, 1);
                }
        }
                }
        }
-}      /*end of ijxout*/
+}
 
 jalign(xp, sp)
        register struct exp *xp;
        register struct symtab *sp;
 {
        register        int     mask;
 
 jalign(xp, sp)
        register struct exp *xp;
        register struct symtab *sp;
 {
        register        int     mask;
+#ifdef DEBUG
+       static struct strdesc noname;
+#endif
        /*
         *      Problem with .align
         *
        /*
         *      Problem with .align
         *
@@ -134,7 +156,7 @@ jalign(xp, sp)
         *      So, ridiculous aligns are caught here and converted
         *      to a .align 2, if possible.
         */
         *      So, ridiculous aligns are caught here and converted
         *      to a .align 2, if possible.
         */
-       if (   (xp->e_xtype != XABS)
+       if (   ( (xp->e_xtype & XTYPE) != XABS)
            || (xp->e_xvalue < 0)
            || (xp->e_xvalue > 16)
            ) {
            || (xp->e_xvalue < 0)
            || (xp->e_xvalue > 16)
            ) {
@@ -143,10 +165,10 @@ jalign(xp, sp)
        }
        if (xp->e_xvalue > 2){
                if (passno == 1){
        }
        if (xp->e_xvalue > 2){
                if (passno == 1){
-                 yywarning(".align %d in any segment is NOT preserved by the loader",
-                       xp->e_xvalue);
-                 yywarning(".align %d converted to .align 2",
-                       xp->e_xvalue);
+                       yywarning(".align %d is NOT preserved by the loader",
+                               xp->e_xvalue);
+                       yywarning(".align %d converted to .align 2",
+                               xp->e_xvalue);
                }
                xp->e_xvalue = 2;
        }
                }
                xp->e_xvalue = 2;
        }
@@ -156,6 +178,10 @@ jalign(xp, sp)
                sp->s_jxfear = (1 << xp->e_xvalue) - 1;
                sp->s_type = dotp->e_xtype;
                sp->s_index = dotp-usedot;
                sp->s_jxfear = (1 << xp->e_xvalue) - 1;
                sp->s_type = dotp->e_xtype;
                sp->s_index = dotp-usedot;
+#ifdef DEBUG
+               sp->s_name = (char *)&noname;
+               sp->s_jxline = lineno;
+#endif
                /*
                 *      We guess that the align will take up at least one
                 *      byte in the code output.  We will correct for this
                /*
                 *      We guess that the align will take up at least one
                 *      byte in the code output.  We will correct for this
@@ -174,16 +200,8 @@ jalign(xp, sp)
                njxxx++;
        } else {
                mask = (1 << xp->e_xvalue) - 1;
                njxxx++;
        } else {
                mask = (1 << xp->e_xvalue) - 1;
-               while (dotp->e_xvalue & mask){
-#ifdef UNIX
-                       outb(0);
-#endif UNIX
-#ifdef VMS
-                       *vms_obj_ptr++ = -1;
-                       *vms_obj_ptr++ = 0;
-                       dotp->e_xvalue += 1;
-#endif VMS
-               }
+               while (dotp->e_xvalue & mask)
+                       Outb(0);
        }
 }
 
        }
 }
 
@@ -214,6 +232,9 @@ jxxxfix()
             *  Do a lazy topological sort.
             */
            for (topono = 1, nchange = 1; nchange != 0; topono++){
             *  Do a lazy topological sort.
             */
            for (topono = 1, nchange = 1; nchange != 0; topono++){
+#ifdef lint
+               topno = topno;
+#endif lint
 #ifdef DEBUG
                if (debug)
                        printf("\nSegment %d, topo iteration %d\n",
 #ifdef DEBUG
                if (debug)
                        printf("\nSegment %d, topo iteration %d\n",
@@ -291,7 +312,8 @@ jxxxfix()
 #ifdef DEBUG
                                                if(debug)
                                                printf("Tunnel from %s from line %d\n",
 #ifdef DEBUG
                                                if(debug)
                                                printf("Tunnel from %s from line %d\n",
-                                                       jumpfrom->s_name, lineno);
+                                                       FETCHNAME(jumpfrom),
+                                                       jumpfrom->s_jxline);
 #endif
                                                continue;
                                } else {        /*tunneling not possible*/
 #endif
                                                continue;
                                } else {        /*tunneling not possible*/
@@ -313,7 +335,7 @@ jxxxfix()
                        if (displ >= 0) {
                                SEGITERATE(segno, cojumpfrom + 1,0,cointdest,
                                                intdest, ubintdest, ++){
                        if (displ >= 0) {
                                SEGITERATE(segno, cojumpfrom + 1,0,cointdest,
                                                intdest, ubintdest, ++){
-                                       if (intdest->s_value > dest->s_value) 
+                                       if (intdest->s_value >= dest->s_value) 
                                                break; /* beyond destination */
                                        if (intdest->s_tag <= JXQUESTIONABLE)
                                                continue;       /*frozen solid*/
                                                break; /* beyond destination */
                                        if (intdest->s_tag <= JXQUESTIONABLE)
                                                continue;       /*frozen solid*/
@@ -466,9 +488,10 @@ jxxxbump(segno, starthint)
                        if (debug){
                        if (sp->s_dest != 0)
                                printf("Explode jump to %s on line %d\n",
                        if (debug){
                        if (sp->s_dest != 0)
                                printf("Explode jump to %s on line %d\n",
-                                       sp->s_dest->s_name, lineno);
+                                       FETCHNAME(sp->s_dest), sp->s_jxline);
                        else
                        else
-                               printf("Explode an align!\n");
+                               printf("Explode an align! on line %d\n",
+                                       sp->s_jxline);
                        }
 #endif
                        sp->s_tag = JXINACTIVE;
                        }
 #endif
                        sp->s_tag = JXINACTIVE;