Building and Running PL/0

We assume that by now you are familiar with the CSE Instructional Labs and have an account on the Linux servers: ceylon, fiji, sumatra, and tahiti. The instructions below assume you are on one of these machines.
Create a directory for the PL/0 compiler and copy the sources there from /cse/courses/cse401/00au/pl0 .
(The sample commands below all assume you are in your compiler directory.)

cp /cse/courses/cse401/00au/pl0/* .
You need to make sure file permissions are correct: accessible by you, but not by others.

chmod -R  u+rwX,go= .
Check that /usr/bin/g++ and /usr/bin/make are in your PATH, for example, by running which g++ . If it is not the case, add /usr/bin to your PATH.
To compile the PL/0 compiler type, run make in your compiler directory. (You may get a few warnings from the C++ compiler; you can ignore these.) This should produce an executable called plzero.
Now you must either create a PL/0 program, or use one of the provided samples fib.0 or squares.0, which you copied along with the compiler sources. To compile a PL/0 program, run the compiler executable and specify the file with program as an argument. For example, to compile fib.0, run

./plzero fib.0

This will create an assembly language program named fib.s .

Note: The newest version of the compiler allows you to generate assembly code for either the MIPS or x86 architectures.  The default is to generate for MIPS: there is a flag to compile for the x86.   For example:

./plzero fib.0
The assembly language program created in the previous step (using the -m flag) will now be the input to the mips simulator called "SPIM". A prompt-driven gdb-style version of SPIM can be run as


Once in SPIM, load and run your program (say, fib.s) with the following commands (SPIM's prompt is in italic below):

load "fib.s"
(spim) run

A more user-friendly X-based version of SPIM can by run as:


Click on the "load" button and type in your file's name, then click the "run" button.
For more details on running spim or xspim, man pages are available by running

man -M /cse/courses/cse401/spim/man spim
man -M /cse/courses/cse401/spim/man xspim

This file has everything you want to know about SPIM. Do look at it once. It's a great help!
When you are required to submit compiler code, it must run on the Linux servers listed above. If you really need to work under NT, you are on your own, but check out instructions from Fall'99 class here.