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