Contents    Page-10    Prev    Next    Page+10    Index   

Code Generation for Statements

The function genc(code) generates code for a statement. There are only a few kinds of statements:

  1. PROGN
    For each argument statement, generate code.

  2. :=
    Generate the right-hand side into a register using genarith. Then store the register into the location specified by the left-hand side.

  3. GOTO
    Generate a Branch to the label number.

  4. LABEL
    Generate a Label with the label number.

  5. IF
    (IF c p1 p2) can be compiled as:
    IF c GOTO L1;
    p2; GOTO L2; L1: p1; L2:

    Optimizations are discussed later.

    Compile short intrinsic functions in-line. For others, generate subroutine calls.