JACCL Compiler Implementation Project
Phase 2.3: Code Generation for Procedures
Due: April. 12, 1999

To complete a version of your JACCL compiler capable of producing runnable 34000 code, you must generate the instructions to handle procedure and function calls and generate the correct code before and after the bodies of procedures, functions and the main program. Your final output should be an assembly language program that accurately implements the JACCL program provided as input to your compiler. This assembly code should be written to standard output.

To make it easy to process JACCL programs with your compiler, I will provide a short shell script named jc (along with lots of other new odds and ends in the pub/434/phase2.3 sub-directory). This script assumes your executable is named jaccl (as it will be unless you have changed the Makefile I provided). The jc script will expect the name of a JACCL source file as input. To make things look right, the source file's name should end with a .j suffix. The script will run the .j file through your compiler and then take what your compiler wrote to standard output and provide it as input to the 34000 assembler. To make it possible to use #include directives in the assembly code you output (I'll explain why you will need this ability later), the jc script will run your compiler's output through the C pre-processor, cpp, before sending it to the assembler.

The "final" output of this process will be a tmem file, which will be read as input by the wc34000 interpreter program (or the mice interpreter if you decide to trust someone's microcode more than my interpreter). In addition, the script will leave the actual output of your compiler in a file whose name is obtained from the name of the input file by replacing the .j suffix with a .s suffix. Similarly, the output listing produced by the assembler will be stored in a file ending with a .l suffix (this file is actually more useful than the .s file because it shows in which word of memory each line of code is stored).

To enable you to keep your output code separate from error messages and diagnostics, I have written my code so that all output produced by printree, printdecldesc and DumpDecldescs is directed to "stderr". In addition, in case you want to keep the output that goes to standard output and standard error together, my routines start each line of output they produce with a ";". This will cause the assembler to treat such lines as comments.

  • How it All Starts
  • Associating Labels with Procedure Entry Points
  • An Input/Output Library?
  • Debugging Support

  • Computer Science 434
    Department of Computer Science
    Williams College