| CSC467F Compilers and Interpreters | Fall 2005 |
At the start of execution, the following may be presumed.
Beginning after the instructions, space is allocated for variables, and
made addressable via the display, as required. Space required
for intermediate results in the evaluation of expressions is at the top of
the used portion of memory (the Evaluation Stack).
An instruction may occupy one, two, or three words of memory. The first word contains an op-code, specifying which machine operation to perform. The second and third words, if present, contain operands. In the following description, push, pop, and top refer to the memory considered as a stack whose top pointer is mt. Variables a, v, n, x and y are local to the description.
0 ADDR LL ON push (display [LL] + ON)
1 LOAD a := top; pop;
if memory [a] = undefined then error;
push (memory [a])
2 STORE v := top; pop;
a := top; pop;
memory [a] := v
3 PUSH V push (V)
4 PUSHMT push (mt)
5 SETD LL display [LL] := top; pop
6 POPN n := top; pop; pop n times
7 POP pop
8 DUPN n:= top; pop; v:= top; pop; push (v) n times
9 DUP push (top)
10 BR a := top; pop; go to a
11 BF a:= top; pop; v:= top; pop; if v = false then go to a
12 NEG top := - top
13 ADD For operations 13-19:
14 SUB y := top; pop;
15 MUL x := top; pop;
16 DIV n := x op y ;
17 EQ if overflow or zerodivide then error else push (n);
18 LT
19 OR
20 SWAP x:= top; pop; y:= top; pop; push(x); push(y)
21 READC One character of input is read and pushed.
22 PRINTC Print top as character; pop
23 READI Starting at the current character of input, blanks and
line boundaries are read and ignored up to the next
digit or sign (if first non-blank is something else
then error). Then consecutive digits are read up to
the first non-digit; They are converted to an integer
n; push( n ).
24 PRINTI Print top as integer; pop
25 HALT Halt
Note: The following two pseudo instructions, TRON and TROFF, are provided as aids to assist in the debugging of the code generator.
26 TRON Start tracing the execution of machine instructions
if tracing has been enabled.
27 TROFF Stop tracing the execution of machine instructions.
Non-op if tracing not enabled.