add onyx code
[unix-history] / usr / src / usr.bin / pascal / px / interp.c
CommitLineData
43017a6f
KM
1/* Copyright (c) 1979 Regents of the University of California */
2
9a92014d 3static char sccsid[] = "@(#)interp.c 1.9 %G%";
43017a6f
KM
4
5#include <math.h>
9a92014d
KM
6#include "whoami.h"
7#include "objfmt.h"
43017a6f
KM
8#include "vars.h"
9#include "panics.h"
10#include "h02opcs.h"
11#include "machdep.h"
12#include "h01errs.h"
13#include "libpc.h"
14
43017a6f
KM
15/*
16 * program variables
17 */
15834a19 18union disply _display;
43017a6f
KM
19struct disp *_dp;
20long _lino = 0;
21int _argc;
22char **_argv;
23long _mode;
9a92014d
KM
24bool _runtst = TRUE;
25bool _nodump = FALSE;
43017a6f
KM
26long _stlim = 500000;
27long _stcnt = 0;
4411d87f 28long _seed = 1;
9a92014d 29#ifdef VAX
43017a6f 30char *_minptr = (char *)0x7fffffff;
9a92014d
KM
31#else
32char *_minptr = (char *)0xffff;
33#endif VAX
43017a6f
KM
34char *_maxptr = (char *)0;
35long *_pcpcount = (long *)0;
36long _cntrs = 0;
37long _rtns = 0;
38
43017a6f
KM
39/*
40 * standard files
41 */
42char _inwin, _outwin, _errwin;
9a92014d
KM
43struct iorechd _err = {
44 &_errwin, /* fileptr */
43017a6f
KM
45 0, /* lcount */
46 0x7fffffff, /* llimit */
9a92014d
KM
47 &_iob[2], /* fbuf */
48 FILNIL, /* fchain */
43017a6f 49 STDLVL, /* flev */
9a92014d
KM
50 "Message file", /* pfname */
51 FTEXT | FWRITE | EOFF, /* funit */
52 2, /* fblk */
43017a6f
KM
53 1 /* fsize */
54};
55struct iorechd output = {
56 &_outwin, /* fileptr */
57 0, /* lcount */
58 0x7fffffff, /* llimit */
59 &_iob[1], /* fbuf */
60 ERR, /* fchain */
61 STDLVL, /* flev */
62 "standard output", /* pfname */
63 FTEXT | FWRITE | EOFF, /* funit */
64 1, /* fblk */
65 1 /* fsize */
66};
9a92014d
KM
67struct iorechd input = {
68 &_inwin, /* fileptr */
43017a6f
KM
69 0, /* lcount */
70 0x7fffffff, /* llimit */
9a92014d
KM
71 &_iob[0], /* fbuf */
72 OUTPUT, /* fchain */
43017a6f 73 STDLVL, /* flev */
9a92014d
KM
74 "standard input", /* pfname */
75 FTEXT | FREAD | SYNC, /* funit */
76 0, /* fblk */
43017a6f
KM
77 1 /* fsize */
78};
79
9a92014d
KM
80/*
81 * file record variables
82 */
83long _filefre = PREDEF;
84struct iorechd _fchain = {
85 0, 0, 0, 0, /* only use fchain field */
86 INPUT /* fchain */
87};
88struct iorec *_actfile[MAXFILES] = {
89 INPUT,
90 OUTPUT,
91 ERR
92};
93
15834a19
KM
94/*
95 * Px profile array
96 */
97#ifdef PROFILE
98long _profcnts[NUMOPS];
99#endif PROFILE
100
101/*
102 * debugging variables
103 */
104#ifdef DEBUG
105char opc[10];
106long opcptr = 9;
107#endif DEBUG
108\f
43017a6f
KM
109interpreter(base)
110 char *base;
111{
112 union progcntr pc; /* interpreted program cntr */
113 register char *vpc; /* register used for "pc" */
114 struct iorec *curfile; /* active file */
115 register struct stack *stp; /* active stack frame ptr */
116 /*
117 * the following variables are used as scratch
118 */
27d5ae53 119 register char *tcp;
43017a6f 120 register long tl, tl1, tl2;
27d5ae53
KM
121 double td, td1;
122 struct sze8 t8;
43017a6f 123 long *tlp;
9a92014d
KM
124 register short *tsp, *tsp1, ts;
125 bool tb;
43017a6f
KM
126 char *tcp1;
127 struct stack *tstp;
128 struct formalrtn *tfp;
129 union progcntr tpc;
130 struct iorec **ip;
131
27d5ae53
KM
132 /*
133 * Setup sets up any hardware specific parameters before
134 * starting the interpreter. Typically this is inline replaced
135 * by interp.sed to utilize specific machine instructions.
136 */
137 setup();
43017a6f
KM
138 /*
139 * necessary only on systems which do not initialize
140 * memory to zero
141 */
142 for (ip = &_actfile[3]; ip < &_actfile[MAXFILES]; *ip++ = FILNIL)
143 /* void */;
144 /*
145 * set up global environment, then ``call'' the main program
146 */
9a92014d
KM
147 _display.frame[0].locvars = pushsp((long)(2 * sizeof(struct iorec *)));
148 _display.frame[0].locvars += 2 * sizeof(struct iorec *);
149 *(struct iorec **)(_display.frame[0].locvars + OUTPUT_OFF) = OUTPUT;
150 *(struct iorec **)(_display.frame[0].locvars + INPUT_OFF) = INPUT;
151 stp = (struct stack *)pushsp((long)(sizeof(struct stack)));
15834a19 152 _dp = &_display.frame[0];
43017a6f
KM
153 pc.cp = base;
154 for(;;) {
15834a19 155# ifdef DEBUG
43017a6f
KM
156 if (++opcptr == 10)
157 opcptr = 0;
158 opc[opcptr] = *pc.ucp;
15834a19
KM
159# endif DEBUG
160# ifdef PROFILE
161 _profcnts[*pc.ucp]++;
162# endif PROFILE
43017a6f 163 switch (*pc.ucp++) {
43017a6f 164 case O_NODUMP:
4411d87f 165 _nodump = TRUE;
43017a6f
KM
166 /* and fall through */
167 case O_BEG:
168 _dp += 1; /* enter local scope */
169 stp->odisp = *_dp; /* save old display value */
170 tl = *pc.ucp++; /* tl = name size */
171 stp->entry = pc.hdrp; /* pointer to entry info */
4411d87f
KM
172 tl1 = pc.hdrp->framesze;/* tl1 = size of frame */
173 _lino = pc.hdrp->offset;
174 _runtst = pc.hdrp->tests;
175 disableovrflo();
176 if (_runtst)
177 enableovrflo();
9a92014d 178 pc.cp += (int)tl; /* skip over proc hdr info */
43017a6f
KM
179 stp->file = curfile; /* save active file */
180 tcp = pushsp(tl1); /* tcp = new top of stack */
9a92014d
KM
181 if (_runtst) /* zero stack frame */
182 blkclr(tl1, tcp);
183 tcp += (int)tl1; /* offsets of locals are neg */
15834a19
KM
184 _dp->locvars = tcp; /* set new display pointer */
185 _dp->stp = stp;
9a92014d 186 stp->tos = pushsp((long)0); /* set tos pointer */
43017a6f
KM
187 continue;
188 case O_END:
189 PCLOSE(_dp->locvars); /* flush & close local files */
190 stp = _dp->stp;
191 curfile = stp->file; /* restore old active file */
192 *_dp = stp->odisp; /* restore old display entry */
15834a19 193 if (_dp == &_display.frame[1])
43017a6f
KM
194 return; /* exiting main proc ??? */
195 _lino = stp->lino; /* restore lino, pc, dp */
196 pc.cp = stp->pc.cp;
197 _dp = stp->dp;
4411d87f
KM
198 _runtst = stp->entry->tests;
199 disableovrflo();
200 if (_runtst)
201 enableovrflo();
15834a19 202 popsp(stp->entry->framesze + /* pop local vars */
43017a6f
KM
203 sizeof(struct stack) + /* pop stack frame */
204 stp->entry->nargs); /* pop parms */
205 continue;
206 case O_CALL:
207 tl = *pc.cp++;
208 tcp = base + *pc.lp++;/* calc new entry point */
209 tcp += sizeof(short);
210 tcp = base + *(long *)tcp;
9a92014d
KM
211 stp = (struct stack *)
212 pushsp((long)(sizeof(struct stack)));
43017a6f
KM
213 stp->lino = _lino; /* save lino, pc, dp */
214 stp->pc.cp = pc.cp;
215 stp->dp = _dp;
15834a19 216 _dp = &_display.frame[tl]; /* set up new display ptr */
43017a6f
KM
217 pc.cp = tcp;
218 continue;
219 case O_FCALL:
220 tl = *pc.cp++; /* tl = number of args */
221 if (tl == 0)
222 tl = *pc.lp++;
223 tfp = (struct formalrtn *)popaddr();
9a92014d
KM
224 stp = (struct stack *)
225 pushsp((long)(sizeof(struct stack)));
43017a6f
KM
226 stp->lino = _lino; /* save lino, pc, dp */
227 stp->pc.cp = pc.cp;
228 stp->dp = _dp;
229 pc.cp = tfp->entryaddr; /* calc new entry point */
4411d87f
KM
230 if (_runtst) {
231 tpc.sp = pc.sp + 1;
232 tl -= tpc.hdrp->nargs;
233 if (tl != 0) {
234 if (tl > 0)
235 tl += sizeof(int) - 1;
236 else
237 tl -= sizeof(int) - 1;
238 ERROR(ENARGS, tl / sizeof(int));
239 }
43017a6f 240 }
15834a19 241 _dp = &_display.frame[tfp->cbn];/* new display ptr */
9a92014d 242 blkcpy(tfp->cbn * sizeof(struct disp),
15834a19 243 &_display.frame[1], &tfp->disp[tfp->cbn]);
9a92014d 244 blkcpy(tfp->cbn * sizeof(struct disp),
15834a19 245 &tfp->disp[0], &_display.frame[1]);
43017a6f
KM
246 continue;
247 case O_FRTN:
248 tl = *pc.cp++; /* tl = size of return obj */
249 if (tl == 0)
250 tl = *pc.usp++;
9a92014d 251 tcp = pushsp((long)(0));
43017a6f
KM
252 tfp = *(struct formalrtn **)(tcp + tl);
253 blkcpy(tl, tcp, tcp + sizeof(struct formalrtn *));
9a92014d
KM
254 popsp((long)(sizeof(struct formalrtn *)));
255 blkcpy(tfp->cbn * sizeof(struct disp),
15834a19 256 &tfp->disp[tfp->cbn], &_display.frame[1]);
43017a6f
KM
257 continue;
258 case O_FSAV:
259 tfp = (struct formalrtn *)popaddr();
260 tfp->cbn = *pc.cp++; /* blk number of routine */
261 tcp = base + *pc.lp++;/* calc new entry point */
262 tcp += sizeof(short);
263 tfp->entryaddr = base + *(long *)tcp;
9a92014d 264 blkcpy(tfp->cbn * sizeof(struct disp),
15834a19 265 &_display.frame[1], &tfp->disp[0]);
43017a6f
KM
266 pushaddr(tfp);
267 continue;
268 case O_SDUP2:
269 pc.cp++;
270 tl = pop2();
9a92014d
KM
271 push2((short)(tl));
272 push2((short)(tl));
43017a6f
KM
273 continue;
274 case O_SDUP4:
275 pc.cp++;
276 tl = pop4();
277 push4(tl);
278 push4(tl);
279 continue;
280 case O_TRA:
281 pc.cp++;
282 pc.cp += *pc.sp;
283 continue;
284 case O_TRA4:
285 pc.cp++;
286 pc.cp = base + *pc.lp;
287 continue;
288 case O_GOTO:
15834a19
KM
289 tstp = _display.frame[*pc.cp++].stp; /* ptr to
290 exit frame */
43017a6f
KM
291 pc.cp = base + *pc.lp;
292 stp = _dp->stp;
293 while (tstp != stp) {
15834a19 294 if (_dp == &_display.frame[1])
43017a6f
KM
295 ERROR(EGOTO); /* exiting prog ??? */
296 PCLOSE(_dp->locvars); /* close local files */
297 curfile = stp->file; /* restore active file */
298 *_dp = stp->odisp; /* old display entry */
299 _dp = stp->dp; /* restore dp */
300 stp = _dp->stp;
301 }
302 /* pop locals, stack frame, parms, and return values */
9a92014d 303 popsp((long)(stp->tos - pushsp((long)(0))));
43017a6f
KM
304 continue;
305 case O_LINO:
9a92014d 306 if (_dp->stp->tos != pushsp((long)(0)))
43017a6f
KM
307 panic(PSTKNEMP);
308 _lino = *pc.cp++; /* set line number */
309 if (_lino == 0)
310 _lino = *pc.sp++;
9a92014d
KM
311 if (_runtst) {
312 LINO(); /* inc statement count */
313 continue;
314 }
315 _stcnt++;
43017a6f
KM
316 continue;
317 case O_PUSH:
318 tl = *pc.cp++;
319 if (tl == 0)
320 tl = *pc.usp++;
321 tl = (-tl + 1) & ~1;
322 tcp = pushsp(tl);
9a92014d
KM
323 if (_runtst)
324 blkclr(tl, tcp);
43017a6f
KM
325 continue;
326 case O_IF:
327 pc.cp++;
4411d87f 328 if (pop2()) {
43017a6f 329 pc.sp++;
4411d87f
KM
330 continue;
331 }
332 pc.cp += *pc.sp;
43017a6f
KM
333 continue;
334 case O_REL2:
335 tl = pop2();
336 tl1 = pop2();
337 goto cmplong;
338 case O_REL24:
339 tl = pop2();
340 tl1 = pop4();
341 goto cmplong;
342 case O_REL42:
343 tl = pop4();
344 tl1 = pop2();
345 goto cmplong;
346 case O_REL4:
347 tl = pop4();
348 tl1 = pop4();
349 cmplong:
350 tl2 = *pc.cp++;
351 switch (tl2) {
352 case releq:
353 push2(tl1 == tl);
354 continue;
355 case relne:
356 push2(tl1 != tl);
357 continue;
358 case rellt:
359 push2(tl1 < tl);
360 continue;
361 case relgt:
362 push2(tl1 > tl);
363 continue;
364 case relle:
365 push2(tl1 <= tl);
366 continue;
367 case relge:
368 push2(tl1 >= tl);
369 continue;
370 default:
371 panic(PSYSTEM);
372 continue;
373 }
374 case O_RELG:
375 tl2 = *pc.cp++; /* tc has jump opcode */
376 tl = *pc.usp++; /* tl has comparison length */
377 tl1 = (tl + 1) & ~1; /* tl1 has arg stack length */
9a92014d 378 tcp = pushsp((long)(0));/* tcp pts to first arg */
43017a6f
KM
379 switch (tl2) {
380 case releq:
9a92014d 381 tb = RELEQ(tl, tcp + tl1, tcp);
43017a6f
KM
382 break;
383 case relne:
9a92014d 384 tb = RELNE(tl, tcp + tl1, tcp);
43017a6f
KM
385 break;
386 case rellt:
9a92014d 387 tb = RELSLT(tl, tcp + tl1, tcp);
43017a6f
KM
388 break;
389 case relgt:
9a92014d 390 tb = RELSGT(tl, tcp + tl1, tcp);
43017a6f
KM
391 break;
392 case relle:
9a92014d 393 tb = RELSLE(tl, tcp + tl1, tcp);
43017a6f
KM
394 break;
395 case relge:
9a92014d 396 tb = RELSGE(tl, tcp + tl1, tcp);
43017a6f
KM
397 break;
398 default:
399 panic(PSYSTEM);
400 break;
401 }
402 popsp(tl1 << 1);
9a92014d 403 push2((short)(tb));
43017a6f
KM
404 continue;
405 case O_RELT:
406 tl2 = *pc.cp++; /* tc has jump opcode */
407 tl1 = *pc.usp++; /* tl1 has comparison length */
9a92014d 408 tcp = pushsp((long)(0));/* tcp pts to first arg */
43017a6f
KM
409 switch (tl2) {
410 case releq:
9a92014d 411 tb = RELEQ(tl1, tcp + tl1, tcp);
43017a6f
KM
412 break;
413 case relne:
9a92014d 414 tb = RELNE(tl1, tcp + tl1, tcp);
43017a6f
KM
415 break;
416 case rellt:
9a92014d 417 tb = RELTLT(tl1, tcp + tl1, tcp);
43017a6f
KM
418 break;
419 case relgt:
9a92014d 420 tb = RELTGT(tl1, tcp + tl1, tcp);
43017a6f
KM
421 break;
422 case relle:
9a92014d 423 tb = RELTLE(tl1, tcp + tl1, tcp);
43017a6f
KM
424 break;
425 case relge:
9a92014d 426 tb = RELTGE(tl1, tcp + tl1, tcp);
43017a6f
KM
427 break;
428 default:
429 panic(PSYSTEM);
430 break;
431 }
432 popsp(tl1 << 1);
9a92014d 433 push2((short)(tb));
43017a6f
KM
434 continue;
435 case O_REL28:
436 td = pop2();
437 td1 = pop8();
438 goto cmpdbl;
439 case O_REL48:
440 td = pop4();
441 td1 = pop8();
442 goto cmpdbl;
443 case O_REL82:
444 td = pop8();
445 td1 = pop2();
446 goto cmpdbl;
447 case O_REL84:
448 td = pop8();
449 td1 = pop4();
450 goto cmpdbl;
451 case O_REL8:
452 td = pop8();
453 td1 = pop8();
454 cmpdbl:
455 switch (*pc.cp++) {
456 case releq:
457 push2(td1 == td);
458 continue;
459 case relne:
460 push2(td1 != td);
461 continue;
462 case rellt:
463 push2(td1 < td);
464 continue;
465 case relgt:
466 push2(td1 > td);
467 continue;
468 case relle:
469 push2(td1 <= td);
470 continue;
471 case relge:
472 push2(td1 >= td);
473 continue;
474 default:
475 panic(PSYSTEM);
476 continue;
477 }
478 case O_AND:
479 pc.cp++;
480 push2(pop2() & pop2());
481 continue;
482 case O_OR:
483 pc.cp++;
484 push2(pop2() | pop2());
485 continue;
486 case O_NOT:
487 pc.cp++;
488 push2(pop2() ^ 1);
489 continue;
490 case O_AS2:
491 pc.cp++;
492 tl = pop2();
493 *(short *)popaddr() = tl;
494 continue;
495 case O_AS4:
496 pc.cp++;
497 tl = pop4();
498 *(long *)popaddr() = tl;
499 continue;
500 case O_AS24:
501 pc.cp++;
502 tl = pop2();
503 *(long *)popaddr() = tl;
504 continue;
505 case O_AS42:
506 pc.cp++;
507 tl = pop4();
508 *(short *)popaddr() = tl;
509 continue;
510 case O_AS21:
511 pc.cp++;
512 tl = pop2();
513 *popaddr() = tl;
514 continue;
515 case O_AS41:
516 pc.cp++;
517 tl = pop4();
518 *popaddr() = tl;
519 continue;
520 case O_AS28:
521 pc.cp++;
522 tl = pop2();
523 *(double *)popaddr() = tl;
524 continue;
525 case O_AS48:
526 pc.cp++;
527 tl = pop4();
528 *(double *)popaddr() = tl;
529 continue;
530 case O_AS8:
531 pc.cp++;
27d5ae53
KM
532 t8 = popsze8();
533 *(struct sze8 *)popaddr() = t8;
43017a6f
KM
534 continue;
535 case O_AS:
536 tl = *pc.cp++;
537 if (tl == 0)
538 tl = *pc.usp++;
539 tl1 = (tl + 1) & ~1;
9a92014d 540 tcp = pushsp((long)(0));
43017a6f
KM
541 blkcpy(tl, tcp, *(char **)(tcp + tl1));
542 popsp(tl1 + sizeof(char *));
543 continue;
544 case O_INX2P2:
545 tl = *pc.cp++; /* tl has shift amount */
546 tl1 = (pop2() - *pc.sp++) << tl;
547 pushaddr(popaddr() + tl1);
548 continue;
549 case O_INX4P2:
550 tl = *pc.cp++; /* tl has shift amount */
551 tl1 = (pop4() - *pc.sp++) << tl;
552 pushaddr(popaddr() + tl1);
553 continue;
554 case O_INX2:
555 tl = *pc.cp++; /* tl has element size */
556 if (tl == 0)
557 tl = *pc.usp++;
558 tl1 = pop2(); /* index */
559 tl2 = *pc.sp++;
43017a6f 560 pushaddr(popaddr() + (tl1 - tl2) * tl);
4411d87f
KM
561 tl = *pc.usp++;
562 if (_runtst)
563 SUBSC(tl1, tl2, tl); /* range check */
43017a6f
KM
564 continue;
565 case O_INX4:
566 tl = *pc.cp++; /* tl has element size */
567 if (tl == 0)
568 tl = *pc.usp++;
569 tl1 = pop4(); /* index */
570 tl2 = *pc.sp++;
43017a6f 571 pushaddr(popaddr() + (tl1 - tl2) * tl);
4411d87f
KM
572 tl = *pc.usp++;
573 if (_runtst)
574 SUBSC(tl1, tl2, tl); /* range check */
43017a6f
KM
575 continue;
576 case O_OFF:
577 tl = *pc.cp++;
578 if (tl == 0)
579 tl = *pc.usp++;
9a92014d 580 pushaddr(popaddr() + tl);
43017a6f
KM
581 continue;
582 case O_NIL:
583 pc.cp++;
584 NIL();
585 continue;
586 case O_ADD2:
587 pc.cp++;
9a92014d 588 push4((long)(pop2() + pop2()));
43017a6f
KM
589 continue;
590 case O_ADD4:
591 pc.cp++;
592 push4(pop4() + pop4());
593 continue;
594 case O_ADD24:
595 pc.cp++;
596 tl = pop2();
597 push4(pop4() + tl);
598 continue;
599 case O_ADD42:
600 pc.cp++;
601 tl = pop4();
602 push4(pop2() + tl);
603 continue;
604 case O_ADD28:
605 pc.cp++;
606 tl = pop2();
607 push8(pop8() + tl);
608 continue;
609 case O_ADD48:
610 pc.cp++;
611 tl = pop4();
612 push8(pop8() + tl);
613 continue;
614 case O_ADD82:
615 pc.cp++;
616 td = pop8();
617 push8(pop2() + td);
618 continue;
619 case O_ADD84:
620 pc.cp++;
621 td = pop8();
622 push8(pop4() + td);
623 continue;
624 case O_SUB2:
625 pc.cp++;
626 tl = pop2();
627 push4(pop2() - tl);
628 continue;
629 case O_SUB4:
630 pc.cp++;
631 tl = pop4();
632 push4(pop4() - tl);
633 continue;
634 case O_SUB24:
635 pc.cp++;
636 tl = pop2();
637 push4(pop4() - tl);
638 continue;
639 case O_SUB42:
640 pc.cp++;
641 tl = pop4();
642 push4(pop2() - tl);
643 continue;
644 case O_SUB28:
645 pc.cp++;
646 tl = pop2();
647 push8(pop8() - tl);
648 continue;
649 case O_SUB48:
650 pc.cp++;
651 tl = pop4();
652 push8(pop8() - tl);
653 continue;
654 case O_SUB82:
655 pc.cp++;
656 td = pop8();
657 push8(pop2() - td);
658 continue;
659 case O_SUB84:
660 pc.cp++;
661 td = pop8();
662 push8(pop4() - td);
663 continue;
664 case O_MUL2:
665 pc.cp++;
9a92014d 666 push4((long)(pop2() * pop2()));
43017a6f
KM
667 continue;
668 case O_MUL4:
669 pc.cp++;
670 push4(pop4() * pop4());
671 continue;
672 case O_MUL24:
673 pc.cp++;
674 tl = pop2();
675 push4(pop4() * tl);
676 continue;
677 case O_MUL42:
678 pc.cp++;
679 tl = pop4();
680 push4(pop2() * tl);
681 continue;
682 case O_MUL28:
683 pc.cp++;
684 tl = pop2();
685 push8(pop8() * tl);
686 continue;
687 case O_MUL48:
688 pc.cp++;
689 tl = pop4();
690 push8(pop8() * tl);
691 continue;
692 case O_MUL82:
693 pc.cp++;
694 td = pop8();
695 push8(pop2() * td);
696 continue;
697 case O_MUL84:
698 pc.cp++;
699 td = pop8();
700 push8(pop4() * td);
701 continue;
702 case O_ABS2:
703 case O_ABS4:
704 pc.cp++;
705 tl = pop4();
706 push4(tl >= 0 ? tl : -tl);
707 continue;
708 case O_ABS8:
709 pc.cp++;
710 td = pop8();
711 push8(td >= 0.0 ? td : -td);
712 continue;
713 case O_NEG2:
714 pc.cp++;
9a92014d 715 push4((long)(-pop2()));
43017a6f
KM
716 continue;
717 case O_NEG4:
718 pc.cp++;
719 push4(-pop4());
720 continue;
721 case O_NEG8:
722 pc.cp++;
723 push8(-pop8());
724 continue;
725 case O_DIV2:
726 pc.cp++;
727 tl = pop2();
728 push4(pop2() / tl);
729 continue;
730 case O_DIV4:
731 pc.cp++;
732 tl = pop4();
733 push4(pop4() / tl);
734 continue;
735 case O_DIV24:
736 pc.cp++;
737 tl = pop2();
738 push4(pop4() / tl);
739 continue;
740 case O_DIV42:
741 pc.cp++;
742 tl = pop4();
743 push4(pop2() / tl);
744 continue;
745 case O_MOD2:
746 pc.cp++;
747 tl = pop2();
748 push4(pop2() % tl);
749 continue;
750 case O_MOD4:
751 pc.cp++;
752 tl = pop4();
753 push4(pop4() % tl);
754 continue;
755 case O_MOD24:
756 pc.cp++;
757 tl = pop2();
758 push4(pop4() % tl);
759 continue;
760 case O_MOD42:
761 pc.cp++;
762 tl = pop4();
763 push4(pop2() % tl);
764 continue;
765 case O_ADD8:
766 pc.cp++;
767 push8(pop8() + pop8());
768 continue;
769 case O_SUB8:
770 pc.cp++;
771 td = pop8();
772 push8(pop8() - td);
773 continue;
774 case O_MUL8:
775 pc.cp++;
776 push8(pop8() * pop8());
777 continue;
778 case O_DVD8:
779 pc.cp++;
780 td = pop8();
781 push8(pop8() / td);
782 continue;
783 case O_STOI:
784 pc.cp++;
9a92014d 785 push4((long)(pop2()));
43017a6f
KM
786 continue;
787 case O_STOD:
788 pc.cp++;
789 td = pop2();
790 push8(td);
791 continue;
792 case O_ITOD:
793 pc.cp++;
794 td = pop4();
795 push8(td);
796 continue;
797 case O_ITOS:
798 pc.cp++;
9a92014d 799 push2((short)(pop4()));
43017a6f
KM
800 continue;
801 case O_DVD2:
802 pc.cp++;
803 td = pop2();
804 push8(pop2() / td);
805 continue;
806 case O_DVD4:
807 pc.cp++;
808 td = pop4();
809 push8(pop4() / td);
810 continue;
811 case O_DVD24:
812 pc.cp++;
813 td = pop2();
814 push8(pop4() / td);
815 continue;
816 case O_DVD42:
817 pc.cp++;
818 td = pop4();
819 push8(pop2() / td);
820 continue;
821 case O_DVD28:
822 pc.cp++;
823 td = pop2();
824 push8(pop8() / td);
825 continue;
826 case O_DVD48:
827 pc.cp++;
828 td = pop4();
829 push8(pop8() / td);
830 continue;
831 case O_DVD82:
832 pc.cp++;
833 td = pop8();
834 push8(pop2() / td);
835 continue;
836 case O_DVD84:
837 pc.cp++;
838 td = pop8();
839 push8(pop4() / td);
840 continue;
841 case O_RV1:
15834a19 842 tcp = _display.raw[*pc.ucp++];
9a92014d 843 push2((short)(*(tcp + *pc.sp++)));
43017a6f
KM
844 continue;
845 case O_RV14:
15834a19 846 tcp = _display.raw[*pc.ucp++];
9a92014d 847 push4((long)(*(tcp + *pc.sp++)));
43017a6f
KM
848 continue;
849 case O_RV2:
15834a19 850 tcp = _display.raw[*pc.ucp++];
43017a6f
KM
851 push2(*(short *)(tcp + *pc.sp++));
852 continue;
853 case O_RV24:
15834a19 854 tcp = _display.raw[*pc.ucp++];
9a92014d 855 push4((long)(*(short *)(tcp + *pc.sp++)));
43017a6f
KM
856 continue;
857 case O_RV4:
15834a19 858 tcp = _display.raw[*pc.ucp++];
43017a6f
KM
859 push4(*(long *)(tcp + *pc.sp++));
860 continue;
861 case O_RV8:
15834a19 862 tcp = _display.raw[*pc.ucp++];
27d5ae53 863 pushsze8(*(struct sze8 *)(tcp + *pc.sp++));
43017a6f
KM
864 continue;
865 case O_RV:
15834a19 866 tcp = _display.raw[*pc.ucp++];
43017a6f
KM
867 tcp += *pc.sp++;
868 tl = *pc.usp++;
c3c85287 869 tcp1 = pushsp((tl + 1) & ~1);
43017a6f
KM
870 blkcpy(tl, tcp, tcp1);
871 continue;
872 case O_LV:
15834a19 873 tcp = _display.raw[*pc.ucp++];
43017a6f
KM
874 pushaddr(tcp + *pc.sp++);
875 continue;
876 case O_LRV1:
15834a19 877 tcp = _display.raw[*pc.ucp++];
9a92014d 878 push2((short)(*(tcp + *pc.lp++)));
43017a6f
KM
879 continue;
880 case O_LRV14:
15834a19 881 tcp = _display.raw[*pc.ucp++];
9a92014d 882 push4((long)(*(tcp + *pc.lp++)));
43017a6f
KM
883 continue;
884 case O_LRV2:
15834a19 885 tcp = _display.raw[*pc.ucp++];
43017a6f
KM
886 push2(*(short *)(tcp + *pc.lp++));
887 continue;
888 case O_LRV24:
15834a19 889 tcp = _display.raw[*pc.ucp++];
9a92014d 890 push4((long)(*(short *)(tcp + *pc.lp++)));
43017a6f
KM
891 continue;
892 case O_LRV4:
15834a19 893 tcp = _display.raw[*pc.ucp++];
43017a6f
KM
894 push4(*(long *)(tcp + *pc.lp++));
895 continue;
896 case O_LRV8:
15834a19 897 tcp = _display.raw[*pc.ucp++];
27d5ae53 898 pushsze8(*(struct sze8 *)(tcp + *pc.lp++));
43017a6f
KM
899 continue;
900 case O_LRV:
15834a19 901 tcp = _display.raw[*pc.ucp++];
9a92014d 902 tcp += (int)*pc.lp++;
43017a6f 903 tl = *pc.usp++;
9a92014d 904 tcp1 = pushsp((tl + 1) & ~1);
43017a6f
KM
905 blkcpy(tl, tcp, tcp1);
906 continue;
907 case O_LLV:
15834a19 908 tcp = _display.raw[*pc.ucp++];
43017a6f
KM
909 pushaddr(tcp + *pc.lp++);
910 continue;
911 case O_IND1:
912 pc.cp++;
9a92014d 913 push2((short)(*popaddr()));
43017a6f
KM
914 continue;
915 case O_IND14:
916 pc.cp++;
9a92014d 917 push4((long)(*popaddr()));
43017a6f
KM
918 continue;
919 case O_IND2:
920 pc.cp++;
921 push2(*(short *)(popaddr()));
922 continue;
923 case O_IND24:
924 pc.cp++;
9a92014d 925 push4((long)(*(short *)(popaddr())));
43017a6f
KM
926 continue;
927 case O_IND4:
928 pc.cp++;
929 push4(*(long *)(popaddr()));
930 continue;
931 case O_IND8:
932 pc.cp++;
27d5ae53 933 pushsze8(*(struct sze8 *)(popaddr()));
43017a6f
KM
934 continue;
935 case O_IND:
936 tl = *pc.cp++;
937 if (tl == 0)
938 tl = *pc.usp++;
939 tcp = popaddr();
940 tcp1 = pushsp((tl + 1) & ~1);
941 blkcpy(tl, tcp, tcp1);
942 continue;
943 case O_CON1:
9a92014d 944 push2((short)(*pc.cp++));
43017a6f
KM
945 continue;
946 case O_CON14:
9a92014d 947 push4((long)(*pc.cp++));
43017a6f
KM
948 continue;
949 case O_CON2:
950 pc.cp++;
951 push2(*pc.sp++);
952 continue;
953 case O_CON24:
954 pc.cp++;
9a92014d 955 push4((long)(*pc.sp++));
43017a6f
KM
956 continue;
957 case O_CON4:
958 pc.cp++;
959 push4(*pc.lp++);
960 continue;
961 case O_CON8:
962 pc.cp++;
9a92014d 963 push8(*pc.dbp++);
43017a6f
KM
964 continue;
965 case O_CON:
966 tl = *pc.cp++;
967 if (tl == 0)
968 tl = *pc.usp++;
969 tl = (tl + 1) & ~1;
970 tcp = pushsp(tl);
971 blkcpy(tl, pc.cp, tcp);
9a92014d
KM
972 pc.cp += (int)tl;
973 continue;
974 case O_CONG:
975 tl = *pc.cp++;
976 if (tl == 0)
977 tl = *pc.usp++;
978 tl1 = (tl + 1) & ~1;
979 tcp = pushsp(tl1);
980 blkcpy(tl1, pc.cp, tcp);
981 pc.cp += (int)((tl + 2) & ~1);
43017a6f
KM
982 continue;
983 case O_LVCON:
984 tl = *pc.cp++;
985 if (tl == 0)
986 tl = *pc.usp++;
987 tl = (tl + 1) & ~1;
988 pushaddr(pc.cp);
9a92014d 989 pc.cp += (int)tl;
43017a6f
KM
990 continue;
991 case O_RANG2:
992 tl = *pc.cp++;
993 if (tl == 0)
994 tl = *pc.sp++;
995 tl1 = pop2();
9a92014d 996 push2((short)(RANG4(tl1, tl, *pc.sp++)));
43017a6f
KM
997 continue;
998 case O_RANG42:
999 tl = *pc.cp++;
1000 if (tl == 0)
1001 tl = *pc.sp++;
1002 tl1 = pop4();
1003 push4(RANG4(tl1, tl, *pc.sp++));
1004 continue;
1005 case O_RSNG2:
1006 tl = *pc.cp++;
1007 if (tl == 0)
1008 tl = *pc.sp++;
1009 tl1 = pop2();
9a92014d 1010 push2((short)(RSNG4(tl1, tl)));
43017a6f
KM
1011 continue;
1012 case O_RSNG42:
1013 tl = *pc.cp++;
1014 if (tl == 0)
1015 tl = *pc.sp++;
1016 tl1 = pop4();
1017 push4(RSNG4(tl1, tl));
1018 continue;
1019 case O_RANG4:
1020 pc.cp++;
1021 tl = *pc.lp++;
1022 tl1 = pop4();
1023 push4(RANG4(tl1, tl, *pc.lp++));
1024 continue;
1025 case O_RANG24:
1026 pc.cp++;
1027 tl = *pc.lp++;
1028 tl1 = pop2();
9a92014d 1029 push2((short)(RANG4(tl1, tl, *pc.lp++)));
43017a6f
KM
1030 continue;
1031 case O_RSNG4:
1032 pc.cp++;
1033 tl = pop4();
1034 push4(RSNG4(tl, *pc.lp++));
1035 continue;
1036 case O_RSNG24:
1037 pc.cp++;
1038 tl = pop2();
9a92014d 1039 push2((short)(RSNG4(tl, *pc.lp++)));
43017a6f
KM
1040 continue;
1041 case O_STLIM:
1042 pc.cp++;
c9065fb5 1043 STLIM();
9a92014d 1044 popsp((long)(sizeof(long)));
43017a6f
KM
1045 continue;
1046 case O_LLIMIT:
1047 pc.cp++;
1048 LLIMIT();
9a92014d 1049 popsp((long)(sizeof(char *)+sizeof(long)));
43017a6f
KM
1050 continue;
1051 case O_BUFF:
9a92014d 1052 BUFF((long)(*pc.cp++));
43017a6f
KM
1053 continue;
1054 case O_HALT:
1055 pc.cp++;
1056 panic(PHALT);
1057 continue;
1058 case O_PXPBUF:
1059 pc.cp++;
1060 _cntrs = *pc.lp++;
1061 _rtns = *pc.lp++;
9a92014d 1062 NEWZ(&_pcpcount, (_cntrs + 1) * sizeof(long));
43017a6f
KM
1063 continue;
1064 case O_COUNT:
1065 pc.cp++;
1066 _pcpcount[*pc.usp++]++;
1067 continue;
1068 case O_CASE1OP:
1069 tl = *pc.cp++; /* tl = number of cases */
1070 if (tl == 0)
1071 tl = *pc.usp++;
1072 tsp = pc.sp + tl; /* ptr to end of jump table */
1073 tcp = (char *)tsp; /* tcp = ptr to case values */
1074 tl1 = pop2(); /* tl1 = element to find */
1075 for(; tl > 0; tl--) /* look for element */
1076 if (tl1 == *tcp++)
1077 break;
1078 if (tl == 0) /* default case => error */
5b37c705 1079 ERROR(ECASE, tl1);
43017a6f
KM
1080 pc.cp += *(tsp - tl);
1081 continue;
1082 case O_CASE2OP:
1083 tl = *pc.cp++; /* tl = number of cases */
1084 if (tl == 0)
1085 tl = *pc.usp++;
1086 tsp = pc.sp + tl; /* ptr to end of jump table */
1087 tsp1 = tsp; /* tsp1 = ptr to case values */
1088 tl1 = (unsigned short)pop2();/* tl1 = element to find */
1089 for(; tl > 0; tl--) /* look for element */
1090 if (tl1 == *tsp1++)
1091 break;
1092 if (tl == 0) /* default case => error */
5b37c705 1093 ERROR(ECASE, tl1);
43017a6f
KM
1094 pc.cp += *(tsp - tl);
1095 continue;
1096 case O_CASE4OP:
1097 tl = *pc.cp++; /* tl = number of cases */
1098 if (tl == 0)
1099 tl = *pc.usp++;
1100 tsp = pc.sp + tl; /* ptr to end of jump table */
1101 tlp = (long *)tsp; /* tlp = ptr to case values */
1102 tl1 = pop4(); /* tl1 = element to find */
1103 for(; tl > 0; tl--) /* look for element */
1104 if (tl1 == *tlp++)
1105 break;
1106 if (tl == 0) /* default case => error */
5b37c705 1107 ERROR(ECASE, tl1);
43017a6f
KM
1108 pc.cp += *(tsp - tl);
1109 continue;
1110 case O_ADDT:
1111 tl = *pc.cp++; /* tl has comparison length */
1112 if (tl == 0)
1113 tl = *pc.usp++;
9a92014d 1114 tcp = pushsp((long)(0));/* tcp pts to first arg */
43017a6f
KM
1115 ADDT(tcp + tl, tcp + tl, tcp, tl >> 2);
1116 popsp(tl);
1117 continue;
1118 case O_SUBT:
1119 tl = *pc.cp++; /* tl has comparison length */
1120 if (tl == 0)
1121 tl = *pc.usp++;
9a92014d 1122 tcp = pushsp((long)(0));/* tcp pts to first arg */
43017a6f
KM
1123 SUBT(tcp + tl, tcp + tl, tcp, tl >> 2);
1124 popsp(tl);
1125 continue;
1126 case O_MULT:
1127 tl = *pc.cp++; /* tl has comparison length */
1128 if (tl == 0)
1129 tl = *pc.usp++;
9a92014d 1130 tcp = pushsp((long)(0));/* tcp pts to first arg */
43017a6f
KM
1131 MULT(tcp + tl, tcp + tl, tcp, tl >> 2);
1132 popsp(tl);
1133 continue;
1134 case O_INCT:
1135 tl = *pc.cp++; /* tl has number of args */
1136 if (tl == 0)
1137 tl = *pc.usp++;
9a92014d
KM
1138 tb = INCT();
1139 popsp(tl*sizeof(long));
1140 push2((short)(tb));
43017a6f
KM
1141 continue;
1142 case O_CTTOT:
1143 tl = *pc.cp++; /* tl has number of args */
1144 if (tl == 0)
1145 tl = *pc.usp++;
1146 tl1 = tl * sizeof(long);
9a92014d 1147 tcp = pushsp((long)(0)) + tl1; /* tcp pts to result */
43017a6f 1148 CTTOT(tcp);
9a92014d 1149 popsp(tl*sizeof(long));
43017a6f
KM
1150 continue;
1151 case O_CARD:
1152 tl = *pc.cp++; /* tl has comparison length */
1153 if (tl == 0)
1154 tl = *pc.usp++;
9a92014d 1155 tcp = pushsp((long)(0));/* tcp pts to set */
43017a6f
KM
1156 tl1 = CARD(tcp, tl);
1157 popsp(tl);
9a92014d 1158 push2((short)(tl1));
43017a6f
KM
1159 continue;
1160 case O_IN:
1161 tl = *pc.cp++; /* tl has comparison length */
1162 if (tl == 0)
1163 tl = *pc.usp++;
1164 tl1 = pop4(); /* tl1 is the element */
9a92014d 1165 tcp = pushsp((long)(0));/* tcp pts to set */
43017a6f 1166 tl2 = *pc.usp++; /* lower bound */
9a92014d 1167 tb = IN(tl1, tl2, (long)(*pc.usp++), tcp);
43017a6f 1168 popsp(tl);
9a92014d 1169 push2((short)(tb));
43017a6f
KM
1170 continue;
1171 case O_ASRT:
1172 pc.cp++;
9a92014d
KM
1173 ts = pop2();
1174 ASRT(ts, "");
43017a6f
KM
1175 continue;
1176 case O_FOR1U:
1177 pc.cp++;
9a92014d 1178 tcp = popaddr(); /* tcp = ptr to index var */
43017a6f 1179 if (*tcp < pop4()) { /* still going up */
4411d87f
KM
1180 tl = *tcp + 1; /* inc index var */
1181 tl1 = *pc.sp++; /* index lower bound */
1182 tl2 = *pc.sp++; /* index upper bound */
1183 if (_runtst)
1184 RANG4(tl, tl1, tl2);
1185 *tcp = tl; /* update index var */
43017a6f
KM
1186 pc.cp += *pc.sp;/* return to top of loop */
1187 continue;
1188 }
4411d87f 1189 pc.sp += 3; /* else fall through */
43017a6f
KM
1190 continue;
1191 case O_FOR2U:
1192 pc.cp++;
9a92014d 1193 tsp = (short *)popaddr(); /* tsp = ptr to index var */
43017a6f 1194 if (*tsp < pop4()) { /* still going up */
4411d87f
KM
1195 tl = *tsp + 1; /* inc index var */
1196 tl1 = *pc.sp++; /* index lower bound */
1197 tl2 = *pc.sp++; /* index upper bound */
1198 if (_runtst)
1199 RANG4(tl, tl1, tl2);
1200 *tsp = tl; /* update index var */
43017a6f
KM
1201 pc.cp += *pc.sp;/* return to top of loop */
1202 continue;
1203 }
4411d87f 1204 pc.sp += 3; /* else fall through */
43017a6f
KM
1205 continue;
1206 case O_FOR4U:
1207 pc.cp++;
9a92014d 1208 tlp = (long *)popaddr(); /* tlp = ptr to index var */
43017a6f 1209 if (*tlp < pop4()) { /* still going up */
4411d87f
KM
1210 tl = *tlp + 1; /* inc index var */
1211 tl1 = *pc.lp++; /* index lower bound */
1212 tl2 = *pc.lp++; /* index upper bound */
1213 if (_runtst)
1214 RANG4(tl, tl1, tl2);
1215 *tlp = tl; /* update index var */
43017a6f
KM
1216 pc.cp += *pc.sp;/* return to top of loop */
1217 continue;
1218 }
4411d87f 1219 pc.sp += 5; /* else fall through */
43017a6f
KM
1220 continue;
1221 case O_FOR1D:
1222 pc.cp++;
9a92014d 1223 tcp = popaddr(); /* tcp = ptr to index var */
43017a6f 1224 if (*tcp > pop4()) { /* still going down */
4411d87f
KM
1225 tl = *tcp - 1; /* inc index var */
1226 tl1 = *pc.sp++; /* index lower bound */
1227 tl2 = *pc.sp++; /* index upper bound */
1228 if (_runtst)
1229 RANG4(tl, tl1, tl2);
1230 *tcp = tl; /* update index var */
43017a6f
KM
1231 pc.cp += *pc.sp;/* return to top of loop */
1232 continue;
1233 }
4411d87f 1234 pc.sp += 3; /* else fall through */
43017a6f
KM
1235 continue;
1236 case O_FOR2D:
1237 pc.cp++;
9a92014d 1238 tsp = (short *)popaddr(); /* tsp = ptr to index var */
43017a6f 1239 if (*tsp > pop4()) { /* still going down */
4411d87f
KM
1240 tl = *tsp - 1; /* inc index var */
1241 tl1 = *pc.sp++; /* index lower bound */
1242 tl2 = *pc.sp++; /* index upper bound */
1243 if (_runtst)
1244 RANG4(tl, tl1, tl2);
1245 *tsp = tl; /* update index var */
43017a6f
KM
1246 pc.cp += *pc.sp;/* return to top of loop */
1247 continue;
1248 }
4411d87f 1249 pc.sp += 3; /* else fall through */
43017a6f
KM
1250 continue;
1251 case O_FOR4D:
1252 pc.cp++;
9a92014d 1253 tlp = (long *)popaddr(); /* tlp = ptr to index var */
43017a6f 1254 if (*tlp > pop4()) { /* still going down */
4411d87f
KM
1255 tl = *tlp - 1; /* inc index var */
1256 tl1 = *pc.lp++; /* index lower bound */
1257 tl2 = *pc.lp++; /* index upper bound */
1258 if (_runtst)
1259 RANG4(tl, tl1, tl2);
1260 *tlp = tl; /* update index var */
43017a6f
KM
1261 pc.cp += *pc.sp;/* return to top of loop */
1262 continue;
1263 }
4411d87f 1264 pc.sp += 5; /* else fall through */
43017a6f
KM
1265 continue;
1266 case O_READE:
1267 pc.cp++;
9a92014d 1268 push2((short)(READE(curfile, base + *pc.lp++)));
43017a6f
KM
1269 continue;
1270 case O_READ4:
1271 pc.cp++;
1272 push4(READ4(curfile));
1273 continue;
1274 case O_READC:
1275 pc.cp++;
9a92014d 1276 push2((short)(READC(curfile)));
43017a6f
KM
1277 continue;
1278 case O_READ8:
1279 pc.cp++;
1280 push8(READ8(curfile));
1281 continue;
1282 case O_READLN:
1283 pc.cp++;
1284 READLN(curfile);
1285 continue;
1286 case O_EOF:
1287 pc.cp++;
9a92014d 1288 push2((short)(TEOF(popaddr())));
43017a6f
KM
1289 continue;
1290 case O_EOLN:
1291 pc.cp++;
9a92014d 1292 push2((short)(TEOLN(popaddr())));
43017a6f
KM
1293 continue;
1294 case O_WRITEC:
1295 pc.cp++;
4411d87f
KM
1296 if (_runtst) {
1297 WRITEC(curfile);
9a92014d 1298 popsp((long)(sizeof(long)+sizeof(FILE *)));
4411d87f
KM
1299 continue;
1300 }
9a92014d 1301#ifdef VAX
4411d87f 1302 fputc();
9a92014d
KM
1303#else
1304 WRITEC(curfile);
1305#endif VAX
1306 popsp((long)(sizeof(long)+sizeof(FILE *)));
43017a6f
KM
1307 continue;
1308 case O_WRITES:
1309 pc.cp++;
4411d87f
KM
1310 if (_runtst) {
1311 WRITES(curfile);
9a92014d 1312 popsp((long)(2*sizeof(char *)+2*sizeof(long)));
4411d87f
KM
1313 continue;
1314 }
9a92014d 1315#ifdef VAX
4411d87f 1316 fwrite();
9a92014d
KM
1317#else
1318 WRITES(curfile);
1319#endif VAX
1320 popsp((long)(2*sizeof(char *)+2*sizeof(long)));
43017a6f
KM
1321 continue;
1322 case O_WRITEF:
4411d87f
KM
1323 if (_runtst) {
1324 WRITEF(curfile);
9a92014d
KM
1325 popsp((long)(((*pc.cp++ - 2) * sizeof(long)) +
1326 2 * sizeof(char *)));
4411d87f
KM
1327 continue;
1328 }
9a92014d 1329#ifdef VAX
4411d87f 1330 fprintf();
9a92014d
KM
1331#else
1332 WRITEF(curfile);
1333#endif VAX
1334 popsp((long)(((*pc.cp++ - 2) * sizeof(long)) +
1335 2 * sizeof(char *)));
43017a6f
KM
1336 continue;
1337 case O_WRITLN:
1338 pc.cp++;
4411d87f
KM
1339 if (_runtst) {
1340 WRITLN(curfile);
1341 continue;
1342 }
1343 fputc('\n', ACTFILE(curfile));
43017a6f
KM
1344 continue;
1345 case O_PAGE:
1346 pc.cp++;
4411d87f
KM
1347 if (_runtst) {
1348 PAGE(curfile);
1349 continue;
1350 }
9a92014d 1351 fputc('\f', ACTFILE(curfile));
43017a6f
KM
1352 continue;
1353 case O_NAM:
1354 pc.cp++;
1355 tl = pop4();
1356 pushaddr(NAM(tl, base + *pc.lp++));
1357 continue;
1358 case O_MAX:
1359 tl = *pc.cp++;
1360 if (tl == 0)
1361 tl = *pc.usp++;
1362 tl1 = pop4();
4411d87f 1363 if (_runtst) {
9a92014d 1364 push4(MAX(tl1, tl, (long)(*pc.usp++)));
4411d87f
KM
1365 continue;
1366 }
1367 tl1 -= tl;
1368 tl = *pc.usp++;
1369 push4(tl1 > tl ? tl1 : tl);
43017a6f
KM
1370 continue;
1371 case O_MIN:
1372 tl = *pc.cp++;
1373 if (tl == 0)
1374 tl = *pc.usp++;
1375 tl1 = pop4();
1376 push4(tl1 < tl ? tl1 : tl);
1377 continue;
1378 case O_UNIT:
1379 pc.cp++;
1380 curfile = UNIT(popaddr());
1381 continue;
1382 case O_UNITINP:
1383 pc.cp++;
1384 curfile = INPUT;
1385 continue;
1386 case O_UNITOUT:
1387 pc.cp++;
1388 curfile = OUTPUT;
1389 continue;
1390 case O_MESSAGE:
1391 pc.cp++;
1392 PFLUSH();
1393 curfile = ERR;
1394 continue;
15834a19
KM
1395 case O_PUT:
1396 pc.cp++;
1397 PUT(curfile);
1398 continue;
43017a6f
KM
1399 case O_GET:
1400 pc.cp++;
1401 GET(curfile);
1402 continue;
1403 case O_FNIL:
1404 pc.cp++;
1405 pushaddr(FNIL(popaddr()));
1406 continue;
1407 case O_DEFNAME:
1408 pc.cp++;
1409 DEFNAME();
9a92014d 1410 popsp((long)(2*sizeof(char *)+2*sizeof(long)));
43017a6f
KM
1411 continue;
1412 case O_RESET:
1413 pc.cp++;
1414 RESET();
9a92014d 1415 popsp((long)(2*sizeof(char *)+2*sizeof(long)));
43017a6f
KM
1416 continue;
1417 case O_REWRITE:
1418 pc.cp++;
1419 REWRITE();
9a92014d 1420 popsp((long)(2*sizeof(char *)+2*sizeof(long)));
43017a6f
KM
1421 continue;
1422 case O_FILE:
1423 pc.cp++;
1424 pushaddr(ACTFILE(curfile));
1425 continue;
1426 case O_REMOVE:
1427 pc.cp++;
1428 REMOVE();
9a92014d 1429 popsp((long)(sizeof(char *)+sizeof(long)));
43017a6f
KM
1430 continue;
1431 case O_FLUSH:
1432 pc.cp++;
1433 FLUSH();
9a92014d 1434 popsp((long)(sizeof(char *)));
43017a6f
KM
1435 continue;
1436 case O_PACK:
1437 pc.cp++;
1438 PACK();
9a92014d 1439 popsp((long)(5*sizeof(long)+2*sizeof(char*)));
43017a6f
KM
1440 continue;
1441 case O_UNPACK:
1442 pc.cp++;
1443 UNPACK();
9a92014d 1444 popsp((long)(5*sizeof(long)+2*sizeof(char*)));
43017a6f
KM
1445 continue;
1446 case O_ARGC:
1447 pc.cp++;
9a92014d 1448 push4((long)_argc);
43017a6f
KM
1449 continue;
1450 case O_ARGV:
1451 tl = *pc.cp++; /* tl = size of char array */
1452 if (tl == 0)
1453 tl = *pc.usp++;
1454 tcp = popaddr(); /* tcp = addr of char array */
1455 tl1 = pop4(); /* tl1 = argv subscript */
1456 ARGV(tl1, tcp, tl);
1457 continue;
1458 case O_CLCK:
1459 pc.cp++;
1460 push4(CLCK());
1461 continue;
1462 case O_WCLCK:
1463 pc.cp++;
1464 push4(time(0));
1465 continue;
1466 case O_SCLCK:
1467 pc.cp++;
1468 push4(SCLCK());
1469 continue;
1470 case O_DISPOSE:
1471 tl = *pc.cp++; /* tl = size being disposed */
1472 if (tl == 0)
1473 tl = *pc.usp++;
1474 tcp = popaddr(); /* ptr to ptr being disposed */
1475 DISPOSE(tcp, tl);
1476 *(char **)tcp = (char *)0;
1477 continue;
1478 case O_NEW:
1479 tl = *pc.cp++; /* tl = size being new'ed */
1480 if (tl == 0)
1481 tl = *pc.usp++;
1482 tcp = popaddr(); /* ptr to ptr being new'ed */
4411d87f
KM
1483 if (_runtst) {
1484 NEWZ(tcp, tl);
1485 continue;
1486 }
1487 NEW(tcp, tl);
43017a6f
KM
1488 continue;
1489 case O_DATE:
1490 pc.cp++;
1491 DATE(popaddr());
1492 continue;
1493 case O_TIME:
1494 pc.cp++;
1495 TIME(popaddr());
1496 continue;
1497 case O_UNDEF:
1498 pc.cp++;
1499 pop8();
9a92014d 1500 push2((short)(0));
43017a6f
KM
1501 continue;
1502 case O_ATAN:
1503 pc.cp++;
1504 push8(atan(pop8()));
1505 continue;
1506 case O_COS:
1507 pc.cp++;
1508 push8(cos(pop8()));
1509 continue;
1510 case O_EXP:
1511 pc.cp++;
1512 push8(exp(pop8()));
1513 continue;
1514 case O_LN:
1515 pc.cp++;
4411d87f
KM
1516 if (_runtst) {
1517 push8(LN(pop8()));
1518 continue;
1519 }
1520 push8(log(pop8()));
43017a6f
KM
1521 continue;
1522 case O_SIN:
1523 pc.cp++;
1524 push8(sin(pop8()));
1525 continue;
1526 case O_SQRT:
1527 pc.cp++;
4411d87f
KM
1528 if (_runtst) {
1529 push8(SQRT(pop8()));
1530 continue;
1531 }
1532 push8(sqrt(pop8()));
43017a6f
KM
1533 continue;
1534 case O_CHR2:
1535 case O_CHR4:
1536 pc.cp++;
4411d87f 1537 if (_runtst) {
9a92014d 1538 push2((short)(CHR(pop4())));
4411d87f
KM
1539 continue;
1540 }
9a92014d 1541 push2((short)(pop4()));
43017a6f
KM
1542 continue;
1543 case O_ODD2:
1544 case O_ODD4:
1545 pc.cp++;
9a92014d 1546 push2((short)(pop4() & 1));
43017a6f
KM
1547 continue;
1548 case O_SUCC2:
15834a19
KM
1549 tl = *pc.cp++;
1550 if (tl == 0)
1551 tl = *pc.sp++;
1552 tl1 = pop4();
4411d87f 1553 if (_runtst) {
9a92014d 1554 push2((short)(SUCC(tl1, tl, (long)(*pc.sp++))));
4411d87f
KM
1555 continue;
1556 }
9a92014d 1557 push2((short)(tl1 + 1));
4411d87f 1558 pc.sp++;
43017a6f
KM
1559 continue;
1560 case O_SUCC24:
15834a19
KM
1561 tl = *pc.cp++;
1562 if (tl == 0)
1563 tl = *pc.sp++;
1564 tl1 = pop4();
4411d87f 1565 if (_runtst) {
9a92014d 1566 push4(SUCC(tl1, tl, (long)(*pc.sp++)));
4411d87f
KM
1567 continue;
1568 }
1569 push4(tl1 + 1);
1570 pc.sp++;
15834a19 1571 continue;
43017a6f 1572 case O_SUCC4:
15834a19
KM
1573 tl = *pc.cp++;
1574 if (tl == 0)
1575 tl = *pc.lp++;
1576 tl1 = pop4();
4411d87f 1577 if (_runtst) {
9a92014d 1578 push4(SUCC(tl1, tl, (long)(*pc.lp++)));
4411d87f
KM
1579 continue;
1580 }
1581 push4(tl1 + 1);
1582 pc.lp++;
43017a6f
KM
1583 continue;
1584 case O_PRED2:
15834a19
KM
1585 tl = *pc.cp++;
1586 if (tl == 0)
1587 tl = *pc.sp++;
1588 tl1 = pop4();
4411d87f 1589 if (_runtst) {
9a92014d 1590 push2((short)(PRED(tl1, tl, (long)(*pc.sp++))));
4411d87f
KM
1591 continue;
1592 }
9a92014d 1593 push2((short)(tl1 - 1));
4411d87f 1594 pc.sp++;
43017a6f
KM
1595 continue;
1596 case O_PRED24:
15834a19
KM
1597 tl = *pc.cp++;
1598 if (tl == 0)
1599 tl = *pc.sp++;
1600 tl1 = pop4();
4411d87f 1601 if (_runtst) {
9a92014d 1602 push4(PRED(tl1, tl, (long)(*pc.sp++)));
4411d87f
KM
1603 continue;
1604 }
1605 push4(tl1 - 1);
1606 pc.sp++;
15834a19 1607 continue;
43017a6f 1608 case O_PRED4:
15834a19
KM
1609 tl = *pc.cp++;
1610 if (tl == 0)
1611 tl = *pc.lp++;
1612 tl1 = pop4();
4411d87f 1613 if (_runtst) {
9a92014d 1614 push4(PRED(tl1, tl, (long)(*pc.lp++)));
4411d87f
KM
1615 continue;
1616 }
1617 push4(tl1 - 1);
1618 pc.lp++;
43017a6f
KM
1619 continue;
1620 case O_SEED:
1621 pc.cp++;
1622 push4(SEED(pop4()));
1623 continue;
1624 case O_RANDOM:
1625 pc.cp++;
1626 push8(RANDOM(pop8()));
1627 continue;
1628 case O_EXPO:
1629 pc.cp++;
1630 push4(EXPO(pop8()));
1631 continue;
1632 case O_SQR2:
1633 case O_SQR4:
1634 pc.cp++;
1635 tl = pop4();
1636 push4(tl * tl);
1637 continue;
1638 case O_SQR8:
1639 pc.cp++;
1640 td = pop8();
1641 push8(td * td);
1642 continue;
1643 case O_ROUND:
1644 pc.cp++;
1645 push4(ROUND(pop8()));
1646 continue;
1647 case O_TRUNC:
1648 pc.cp++;
1649 push4(TRUNC(pop8()));
1650 continue;
9a92014d
KM
1651 default:
1652 panic(PBADOP);
1653 continue;
43017a6f
KM
1654 }
1655 }
1656}