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