Stage 5 of the
Klein compiler project
OUT: Friday, October 27
DUE: Friday, November 10
STATUS CHECK DUE: Friday, November 3
This stage consists of a minimal implementation of the fourth component of your Klein compiler, supporting documentation, and one auxiliary program.
To complete this project, you need to be able to execute a TM program. See below for details on downloading the TM virtual machine and for using it for the project.
Write a minimal run-time environment and code generator for Klein programs.A code generator is a function or object that takes as input:
function main() : integer print(1) 1This requires implementing the primitive print procedure in TM and implementing run-time support for calling functions. Even though this main function takes no arguments and the print function always takes one argument, you should implement your code generator so that it looks up the number arguments when generating the stack frame and computing locations.
Document the design of your run-time environment using text and diagrams of memory organization.Create three diagrams:
Create a Unix command-line script named kleinc that compiles a Klein program into a TM program.kleinc should take the name of a Klein source program as its argument, run your parser, semantic checker, and code generator on it, and produce a TM program of the same name. That is, compiling print-one.kln will produce a program named print-one.tm.
As before, submit only one copy of each assignment per team, both electronically and on paper. The team captain or a designated team member can be responsible for the submission.
Users can provide arguments to main on the command line.Thanks to Mike Volz, CS 4550 Class of Fall 2007, we have an extended TM simulator that supports command-line arguments. For example,
> tm factorial-cli.tm 10 TM simulation (enter h for help)... Enter command: g OUT instruction prints: 3628800 HALT: 0,0,0 Halted Enter command: q Simulation done.