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