Code Generation
From Wiki**3
Topics
- Interpretation: syntax-directed and based on abstract syntax tree.
- Code generation: syntax-directed and based on abstract syntax tree.
The Postfix Machine
SL0 - single stack, large stack, 0 operand machine.
Three special purpose registers: IP (instruction pointer), for jumps and function calls; FP (frame pointer), the basis of the frame pointer for each function; SP (stack pointer), keeps track of the top of the stack.
The stack grows in the direction of lower addresses.
Almost all operations use the stack as input and output (exceptions are PUSH and POP, for returning values from functions in accordance with CDecl), and instructions that use either immediate arguments or arguments in global memory (i.e., with explicit named addressing).
Basic Structures (code)
While Cycles
"Break" and "Continue" Instructions
If-Then and If-Then-Else Instructions
Basic Structures (data)
Functions
Global (permanent) variables
We include in this category C-like "static" function variables (the only difference is that they are not accessed with their explicit names, but rather with a automatic symbol table-based name).