|
|
1.1 root 1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
2:
3: * /////////////////////////////////////
4: * /////////////////////////////////////
5: * /////////////// run.c ///////////////
6: * /// J. P. Hawkins WH X4610 8C-001 ///
7: * ///// Fri Aug 24 17:29:21 1979 //////
8: * /////////////////////////////////////
9: * /////////////////////////////////////
10:
11: * RUN BASIC Program
12: */
13: /* "@(#) run.c: V 1.1 12/21/80" */
14:
15: #include "bas.h"
16: #define getout(X)\
17: signal(SIGINT, quit);\
18: stpflg=0;\
19: _comflg=0;\
20: if(X < 0)\
21: error(inst.thing.linno,15);\
22: return(X)
23: int runcnt = 0; /* nest count for run */
24: char *ptr;
25: extern int stopl();
26: extern int singst;
27: extern int stpflg;
28: extern int endfcnt; /* structured "if" nest count */
29: extern int forflg; /* nested for count */
30: extern int bflag,cflag; /* break count */
31: extern int quit();
32: extern int _comflg; /* common flag */
33: run()
34: {
35: singst = 32767;
36: endfcnt = 0; /* initialize "if" nest count */
37: bflag = cflag = 0;
38: forflg = 0;
39: if(!(_comflg)) /* If "common" not issued between last &
40: this invocation of "run" */
41: expunge(); /* de-allocate cariable stack and
42: symbol tables to keep memory optimum */
43: restore();
44: runcnt += 1; /* bump nest count */
45: if(expr[0] != '\0') /* if filename specified */
46: {
47: if(load() < 0) /* load file before running */
48: {
49: runcnt -= 1; /* dec nest count */
50: getout(-1); /* return if load error */
51: }
52: } else {
53: if(runcnt > 1)
54: {
55: error(inst.thing.linno, 6);
56: runcnt -= 1; /* dec nest count */
57: getout(-1);
58: }
59: }
60: if(fetch(0,&ptr) < 0) /* any lines? */
61: {
62: error(inst.thing.linno, 5);
63: runcnt -= 1; /* dec nest count */
64: getout(0); /* nop, can't do anything */
65: }
66: signal(SIGINT, stopl);
67: if(bascall(inst.thing.opcode.lobyte) == -1) /* execute first instruction */
68: {
69: runcnt -= 1; /* dec nest count */
70: getout(-1); /* and return if error */
71: }
72:
73: /*
74: * fetch each instruction sequentially and execute
75: * until last line.
76: * Fetch sets up the xxxxx
77: */
78: while((fetch(-1,&ptr) == 0) && (stpflg == 0))
79: if(bascall(inst.thing.opcode.lobyte) == -1)
80: {
81: runcnt -= 1; /* dec nest count */
82: getout(-1);
83: }
84: runcnt -= 1; /* dec nest count */
85: getout(0);
86: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.