align O_RV, run pc2 after /lib/c2
[unix-history] / usr / src / usr.bin / pascal / px / interp.c
index 1a55db8..809d092 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)interp.c 1.5 %G%";
+static char sccsid[] = "@(#)interp.c 1.8 %G%";
 
 #include <math.h>
 #include "vars.h"
 
 #include <math.h>
 #include "vars.h"
@@ -110,17 +110,24 @@ interpreter(base)
        /*
         * the following variables are used as scratch
         */
        /*
         * the following variables are used as scratch
         */
-       double td, td1;
+       register char *tcp;
        register long tl, tl1, tl2;
        register long tl, tl1, tl2;
+       double td, td1;
+       struct sze8 t8;
        long *tlp;
        short *tsp, *tsp1;
        long *tlp;
        short *tsp, *tsp1;
-       register char *tcp;
        char *tcp1;
        struct stack *tstp;
        struct formalrtn *tfp;
        union progcntr tpc;
        struct iorec **ip;
 
        char *tcp1;
        struct stack *tstp;
        struct formalrtn *tfp;
        union progcntr tpc;
        struct iorec **ip;
 
+       /*
+        * Setup sets up any hardware specific parameters before
+        * starting the interpreter. Typically this is inline replaced
+        * by interp.sed to utilize specific machine instructions.
+        */
+        setup();
        /*
         * necessary only on systems which do not initialize
         * memory to zero
        /*
         * necessary only on systems which do not initialize
         * memory to zero
@@ -510,8 +517,8 @@ interpreter(base)
                        continue;
                case O_AS8:
                        pc.cp++;
                        continue;
                case O_AS8:
                        pc.cp++;
-                       td = pop8();
-                       *(double *)popaddr() = td;
+                       t8 = popsze8();
+                       *(struct sze8 *)popaddr() = t8;
                        continue;
                case O_AS:
                        tl = *pc.cp++;
                        continue;
                case O_AS:
                        tl = *pc.cp++;
@@ -841,13 +848,13 @@ interpreter(base)
                        continue;
                case O_RV8:
                        tcp = _display.raw[*pc.ucp++];
                        continue;
                case O_RV8:
                        tcp = _display.raw[*pc.ucp++];
-                       push8(*(double *)(tcp + *pc.sp++));
+                       pushsze8(*(struct sze8 *)(tcp + *pc.sp++));
                        continue;
                case O_RV:
                        tcp = _display.raw[*pc.ucp++];
                        tcp += *pc.sp++;
                        tl = *pc.usp++;
                        continue;
                case O_RV:
                        tcp = _display.raw[*pc.ucp++];
                        tcp += *pc.sp++;
                        tl = *pc.usp++;
-                       tcp1 = pushsp(tl);
+                       tcp1 = pushsp((tl + 1) & ~1);
                        blkcpy(tl, tcp, tcp1);
                        continue;
                case O_LV:
                        blkcpy(tl, tcp, tcp1);
                        continue;
                case O_LV:
@@ -876,7 +883,7 @@ interpreter(base)
                        continue;
                case O_LRV8:
                        tcp = _display.raw[*pc.ucp++];
                        continue;
                case O_LRV8:
                        tcp = _display.raw[*pc.ucp++];
-                       push8(*(double *)(tcp + *pc.lp++));
+                       pushsze8(*(struct sze8 *)(tcp + *pc.lp++));
                        continue;
                case O_LRV:
                        tcp = _display.raw[*pc.ucp++];
                        continue;
                case O_LRV:
                        tcp = _display.raw[*pc.ucp++];
@@ -911,7 +918,7 @@ interpreter(base)
                        continue;
                case O_IND8:
                        pc.cp++;
                        continue;
                case O_IND8:
                        pc.cp++;
-                       push8(*(double *)(popaddr()));
+                       pushsze8(*(struct sze8 *)(popaddr()));
                        continue;
                case O_IND:
                        tl = *pc.cp++;
                        continue;
                case O_IND:
                        tl = *pc.cp++;
@@ -1048,7 +1055,7 @@ interpreter(base)
                                if (tl1 == *tcp++)
                                        break;
                        if (tl == 0)            /* default case => error */
                                if (tl1 == *tcp++)
                                        break;
                        if (tl == 0)            /* default case => error */
-                               ERROR(ECASE, tl2);
+                               ERROR(ECASE, tl1);
                        pc.cp += *(tsp - tl);
                        continue;
                case O_CASE2OP:
                        pc.cp += *(tsp - tl);
                        continue;
                case O_CASE2OP:
@@ -1062,7 +1069,7 @@ interpreter(base)
                                if (tl1 == *tsp1++)
                                        break;
                        if (tl == 0)            /* default case => error */
                                if (tl1 == *tsp1++)
                                        break;
                        if (tl == 0)            /* default case => error */
-                               ERROR(ECASE, tl2);
+                               ERROR(ECASE, tl1);
                        pc.cp += *(tsp - tl);
                        continue;
                case O_CASE4OP:
                        pc.cp += *(tsp - tl);
                        continue;
                case O_CASE4OP:
@@ -1076,7 +1083,7 @@ interpreter(base)
                                if (tl1 == *tlp++)
                                        break;
                        if (tl == 0)            /* default case => error */
                                if (tl1 == *tlp++)
                                        break;
                        if (tl == 0)            /* default case => error */
-                               ERROR(ECASE, tl2);
+                               ERROR(ECASE, tl1);
                        pc.cp += *(tsp - tl);
                        continue;
                case O_ADDT:
                        pc.cp += *(tsp - tl);
                        continue;
                case O_ADDT: