|
![]() |
![]() |
![]() |
![]() |
We assume that you are familiar with the CSE Instructional Labs and have an account on the instructional Linux servers: ceylon, fiji, sumatra, and tahiti. The instructions below assume you are on one of these machines.
On the instructional Linux systems (e.g. fiji), create a directory for your project and copy the PL/0 compiler sources there. I'd suggest a 2-level structure as follows:
{fiji} (~)% cd {fiji} (~)% mkdir 401 {fiji} (~)% cd 401 {fiji} (~/401)% cp -r /cse/courses/cse401/CurrentQtr/pl0 pl0[Only type what is after the % symbol; the fake prompt is to help you understand from which directory you should type each command.}
You need to make sure file permissions are correct: accessible by you, but not by others.
{fiji} (~/401)% chmod -R u+rwX,go=  pl0
Check that /usr/bin/g++ and /usr/bin/make are in your PATH, for example, by running which g++. If this is not the case, add /usr/bin to your PATH.
To compile and link the PL/0 compiler type:
{fiji} (~/401)% cd pl0 {fiji} (~/401/pl0)% make(You may get a few warnings from the C++ compiler; you can ignore these.) This should produce an executable called plzero.
Now you can test it either by creating a PL/0 program, or using one of the provided samples fib.0 or squares.0, which were copied along with the compiler sources. To compile a PL/0 program called fib.0 type:
{fiji} (~/401/pl0)% ./plzero fib.0This will create an assembly language program named fib.s. 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:
{fiji} (~/401/pl0)% ./plzero -x fib.0
The MIPS assembly language program created in the previous step (using the default or -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
/cse/courses/cse401/spim/linux/bin/spim
Once in SPIM, load and run your program (say,
fib.s) with the following commands (SPIM's prompt
is in italic below):
(spim) load "fib.s"
(spim) run
A more user-friendly X-based version of SPIM can by run
as:
/cse/courses/cse401/spim/linux/bin/xspim
Click on the "load" button and type in your file's name,
then click the "run" button.
For more details on runningspim or
xspim, man pages are available by running
man -M /cse/courses/cse401/spim/man spim
man -M /cse/courses/cse401/spim/man xspim
More information is available about spim in the directory
/cse/courses/cse401/spim/; in particular
the manual has everything you want to know about
SPIM. Do look at it once. It's a great help!
We don't recommend it, but if you'd rather do your development on Windows or NT, start here.
![]() |
Department of Computer Science & Engineering University of Washington Box 352350 Seattle, WA 98195-2350 (206) 543-1695 voice, (206) 543-2969 FAX [comments to cse401-webmaster] |