1: /*
2: * px - Berkeley Pascal interpreter
3: *
4: * Version 1.0, July 1977
5: *
6: * Written by Bill Joy and Chuck Haley
7: * November-December 1976
8: *
9: * Based on an earlier version by Ken Thompson
10: *
11: * Px is described in detail in the "PX 1.0 Implementation Notes"
12: * The source code for px is in several major pieces:
13: *
14: * int.c C main program which reads in interpreter code
15: * 00int.s Driver including main interpreter loop
16: * dd*.s Where dd are digits, interpreter instructions
17: * grouped by their positions in the interpreter table.
18: * p*.c Various C language routines supporting the system.
19: *
20: * In addition there are several headers defining mappings for error
21: * messages names into codes, and a definition of the interpreter transfer
22: * table. These are made by the script Emake in this directory and the scripts
23: * in the directory '../opcodes'.
24: */
25:
26: int argc;
27: char **argv;
28:
29: /*
30: * Pascal runtime errors cause emulator traps
31: * to the routine onemt which transfers to the
32: * routine 'error' in the file perror.c to decode them.
33: * This method saves at least one word per static error.
34: */
35: int onemt();
36:
37: /*
38: * Definitions for memory allocation
39: * Memory allocation routines are in 'palloc.c'
40: */
41: char *bottmem, *memptr, *high, *maxstk;
42:
43: /*
44: * The file i/o routines maintain a notion of a "current file".
45: * The printing name of this file is kept in the variable
46: * "file" for use in error messages.
47: */
48: char *file;
49:
50: /*
51: * THE RUNTIME DISPLAY
52: *
53: * The entries in the display point to the active static block marks.
54: * The first entry in the display is for the global variables,
55: * then the procedure or function at level one, etc.
56: * Each display entry points to a stack frame as shown:
57: *
58: * base of stack frame
59: * ---------------
60: * | |
61: * | block mark |
62: * | |
63: * --------------- <-- display entry points here
64: * | |
65: * | local |
66: * | variables |
67: * | |
68: * ---------------
69: * | |
70: * | expression |
71: * | temporary |
72: * | storage |
73: * | |
74: * - - - - - - - -
75: *
76: * The information in the block mark is thus at positive offsets from
77: * the display pointer entries while the local variables are at negative
78: * offsets. The block mark actually consists of two parts. The first
79: * part is created at CALL and the second at entry, i.e. BEGIN. Thus:
80: *
81: * -------------------------
82: * | |
83: * | Saved lino |
84: * | Saved lc |
85: * | Saved dp |
86: * | |
87: * -------------------------
88: * | |
89: * | Saved (dp) |
90: * | |
91: * | Current section name |
92: * | and entry line ptr |
93: * | |
94: * | Saved file name and |
95: * | file buffer ptr |
96: * | |
97: * | Empty tos value |
98: * | |
99: * -------------------------
100: */
101: int display[20], *dp;
102:
103: int lino;
104: int nodump;
105:
106: /*
107: * Random number generator constants
108: */
109: long seed;
110: double randa;
111: double randc;
112: double randm;
113: double randim;
114:
115: /*
116: * Structures to access things on the stack
117: */
118: struct {
119: char pchar;
120: };
121: struct {
122: int pint;
123: int p2int;
124: };
125: struct {
126: long plong;
127: };
128: struct {
129: double pdouble;
130: };
131:
132: char discard;
Defined variables
argc
defined in line
26; used 7 times
argv
defined in line
27; used 11 times
dp
defined in line
101; used 22 times
- in /usr/src/ucb/pascal/px/00int.s line
9,
38-41(2),
101-102(2),
108,
122,
130-136(3),
158,
167-169(2),
214,
242-245(3),
252-253(2),
267
- in /usr/src/ucb/pascal/px/int.c line
169
- in /usr/src/ucb/pascal/px/perror.c line
145
file
defined in line
48; used 37 times
- in /usr/src/ucb/pascal/px/00int.s line
13,
106,
132,
249,
283,
294
- in /usr/src/ucb/pascal/px/30getname.s line
214
- in /usr/src/ucb/pascal/px/30io.s line
33-38(2),
45,
51,
77,
100,
106,
126,
167,
176,
189-193(2)
- in /usr/src/ucb/pascal/px/30iosubs.s line
7-10(2),
145
- in /usr/src/ucb/pascal/px/int.c line
35-47(6),
60,
75,
104,
122-128(4),
162
- in /usr/src/ucb/pascal/px/perror.c line
80
high
defined in line
41; used 3 times
lino
defined in line
103; used 9 times
seed
defined in line
109;
never used
Usage of this include