This step applies scheme-to-scheme rewrite rules that are required for assembler and not C. At the moment, this consists only of converting forms headed by AND and OR into binary-if statements. This rewrite is simple because the coprocessor's sublanguage does not allow miscellaneous objects to be used in place of booleans.

This step converts the code into a linear sequence of stack machine operations, with symbolic variable names and symbolic jump points. Each operation is a pair consisting of an op-code-name followed (if required) by an argument (numerical argument, symbolic jump point, or variable name).

The basic algorithm is as follows:

- Recursively generate linear output code.
- Generate guards before arithmetic operations (except inside protected groups of forms).
- Expand forms like while and cond into linear code with symbolic jump points. A jump point is an expression of the form (label [a symbol]).
- Remove output from stack for (a) non-final form in begin or suspend-missing-values, (b) form in unary-if, and (d) forms in both branches of binary-if (individually!) when the forms disagree about basic output type.

Step 8 uses type information to determine how to remove output from the stack when required and to distinguish functions that are still overloaded at this stage. The types of variables are stored in the symbol table. The heads of complex expressions have been decorated with their output type at the end of step 6.

- Numerical tests (<, >, <=, >=, missing?) and a number of arithmetic operations (point-coordinate, min, max, +, -, unary-minus, abs, *, sheet-domain-offset, sheet-codomain-offset, sheet-domain-scaling, sheet-codomain-scaling) must be split into integer and real forms.
- Make-point must be split into four cases: real 2D, real 3D, integer 2D, and integer 3D.

Assembler generation disregards the distinction between guaranteed-/ and /, guaranteed-modulo and modulo, and guaranteed-quotient and quotient. The operation - is renamed to minus.

This step converts the code into a linear sequence of stack machine operations. Each operation is list of up to four elements: line-number, op-code-name, argument (if required), variable name (for get/set instructions).

- Assign line numbers to the jump points.
- Coelesce adjacent jump points.
- Convert local variable references into frame pointer offsets.

The output of this step is sent to the coprocessor, for installation in its function table. The interface function translates the op-code names into op-code numbers.

Ownership, Maintenance and Disclaimers

Last modified