Date: Tue, 14 Jan 1997 23:12:51 GMT
Server: Apache/1.0.3
Content-type: text/html
Content-length: 3735
Last-modified: Tue, 19 Nov 1996 16:04:00 GMT
P523 Project Five
P523 Project Five
Fall Semester 96-97
Code Generation
Due 11:59pm Sunday, December 8
Design and implement a code generator for programs in weasel form, using the procedure calling
conventions and pointer and object representations discussed in class.
Your code generator must produce assembly code for the Alpha AXP processor. Use the interpreters
presented in beta.ss and gamma.ss as guidelines for writing your code
generator.
Support Code
cg-help.ss provides
some code generation
utilities:
- symbolic constants for tagging
- open-file opens the assembly output file, scheme.s, and writes
the header
- emit writes assembly instructions to scheme.s
- new-label creates a new assembly language label
- write-label writes a label to scheme.s
- c-imm converts Scheme immediates to tagged Alpha immediates
- close-file writes trailer to scheme.s and closes it
- run-file copies scheme.s to your 431 directory on copper and
executes a remote shell on copper to assemble and run it.
The directory /u/c431/p5 on copper contains support files for making
an executable file from your assembly output file, scheme.s:
- startup.c: allocates and initializes the Scheme stack and heap,
calls your code via the assembly stub call_scheme.s, and prints the
result.
- call_scheme.s: assembly language stub that sets up the Scheme
registers, places the return address onto the base of the frame, calls
your code, and returns to the C caller, startup.c.
- cg.h: assembly language header file that defines constants for
tagging and generating immediates.
You should create the directory copper:431 and copy all the
files from copper:/u/c431/p5 into it. The procedures in
cg-help.ss assume that this directory and your .rhosts file
on copper are set up.
p5trial.alpha in /u/c431/p5 on copper (and
p5trial.sun4 for Suns) defines the procedure c431-cg.
(c431-cg <weasel>) generates Alpha assembly for the weasel
program into the file scheme.s in the current directory.
p5good (in /u/c431/p5 on copper) gives a set of test
cases you may find useful. Each test case is followed by the expected
result in a comment. The result is printed in the same format
startup.c prints it, so you can compare the results quite
easily. p5test.ss provides a Scheme procedure
that will run your code generator on all the test cases in
p5good and create the file tests.out that can be compared
against p5good using diff. Before using this, you must
have the latest version of Makefile and startup.c from
/u/c431/p5.
Project report:
Your project report should contain a description of your code
generator along with the source for the code generator. It should
also contain sample assembly output for several small examples showing
what the code generator produces for a variety of expressions. Follow
the guidelines for documentation, neatness, and collaboration from the
first project assignment.
Late policy:
Project reports may be handed in up to one week late without penalty.
Reports handed in more than one week late will not be graded.