|Teaching compiler courses firstname.lastname@example.org (1991-11-15)|
|Re: Teaching compiler courses Dan.McCue@newcastle.ac.uk (Daniel L. McCue) (1991-11-20)|
|From:||Daniel L. McCue <Dan.McCue@newcastle.ac.uk>|
|Date:||Wed, 20 Nov 91 16:43:24 GMT|
email@example.com (Jim Kadin) writes:
>I am teaching an undergraduate compiler writing course and I would like
>some pointers as to what target language to use for the students'
>Our source language is a subset of Pascal. We will be implementing the
>compilers in C on Sun workstations.
>I've been thinking of using the USCD P-code machine for the target
>Is this a good idea?
I was faced with the same dilemma for my compiler course this term.
I had the following bias:
I didn't want to have the students generate p-code or such-like since
I wanted them to consider register allocation etc.
I didn't want to have them target a real machine (or simulator for a
real machine) because
a) it's *TOO* realistic - you get all the warts of a real machine and
b) unless there was a good simulator for it, the students would have
no help debugging their generated code.
Here's how I solved it:
I designed a simple general register machine - a few dozen instructions, a
couple of addressing modes, no floating-point. I wrote an assembler for
the this machine that generates "a.out" files and a simulator that
provides a graphical display of memory, registers and instructions as the
program is executed.
The code is in C++ and uses X-Windows (through InterViews) for the
displays. The documentation is extremely limited :) Since time was short,
the code is not exactly a polished example of C++ programming, InterViews
programming, asssembler design or simulator design, but it works. I
ported it without difficulty from my Sun workstation to an Encore Multimax
for the students to use. I don't know how portable it is otherwise.
You're welcome to the code.
Send mail if interested to Dan.McCue@newcastle.ac.uk.
Return to the
Search the comp.compilers archives again.