You can have the pl0 compiler generate x86/linux assembly language, which when assembled can run on the native x86 hardware. This is the default.
If you aren't familar with x86 assembly language, then you probably know MIPS assembly language from your assembly language/machine structures class, and so can use the MIPS interpeter called SPIM ("MIPS" backwards!). You might find that MIPS/SPIM is a little easier to debug than native x86/linux instructions.
You can change your mind about what kind of assembly language is generated at any time in the quarter. You only need to use one mechanism, either the x86 or the mips.
On the instructional unix machines, copy the PL/0
compiler sources into your directory by executing:
{ceylon} (~)% cd {ceylon} (~)% mkdir cse401 {ceylon} (~)% cd cse401 {ceylon} (~/cse401)% cp -r /cse/courses/cse401/CurrentQtr/pl0_base pl0Only type what is after the % symbol. I put the fake prompt in to help you understand from which directory you should type each command. |
|
You need to make sure file permissions are correct. First we make
sure all files are accessible by you. Next we remove the temptation
for others to sneek a peek.
{ceylon} (~/cse401)% chmod -R u+rwX pl0 {ceylon} (~/cse401)% chmod -R go-rwx pl0 | |
To compile the PL/0 compiler type:
{ceylon} (~/cse401)% cd pl0 {ceylon} (~/cse401/pl0)% makeYou may get a few warnings from the C++ compiler; you can ignore these. |
|
To get help on plzero invocation flags, do: {ceylon} (~/cse401/pl0)% ./plzero -h |
|
Now you must either create a PL/0 program,
or use one of the provided samples,
either fib.0 or squares.0 ,
which are included with pl0_base .
To compile a PL/0 program
called {ceylon} (~/cse401/pl0)% ./plzero fib.0By default, this will generate an x86/linux assembly language program named fib.s .
| |
The x86/linux assembly code you created in the previous step
can be assembled, the pl0 run time system compiled in,
and everything linked into an executable x86/linux binary
named fib,
by doing:
{ceylon} (~/cse401/pl0)% g++ fib.s rt.x86.c -o fib You can then run the linked binary by doing: {ceylon} (~/cse401/pl0)% ./fib(Invoking this executable using ./ will ensure that you get the program named fib from the current directory.) The program will prompt you with a ? indicating that it is awaiting input. Type the number you want the program to consume. When you are finished with the program, type Control-C to kill the program. |
|
If you aren't familar with x86 assembly language,
and know MIPS assembly language,
then you can use these alternatives.
Alternatively,
to compile a PL/0 program called fib.0 into MIPS/SPIM
code type:
{ceylon} (~/cse401/pl0)% ./plzero -m fib.0The -m flag will tell the compiler to create an mips format assembly language program fib.s .
|
|
(Note that as of 07Oct01 Robert Henry hasn't actually checked
that this works.)
The MIPS assembly language program created in the previous step will
now be the input to the mips simulator called spim.
To get spim running do the following :
1. Add
/cse/courses/cse401/spim/linux/bin
to your PATH.
( Depending on the shell you have, you can use setenv or export
to do this )
2. Now you can start spim by typing:
{ceylon} (~/cse401/pl0)% spim3. You can also start a more user friendly xterm version of spim by typing: {ceylon} (~/cse401/pl0)% xspim4. To get your assembly program running, at the spim prompt (after you have started spim), enter : {ceylon} (~/cse401/pl0)(spim) load "fib.s"In the X version you can simply click on the load button, and it will ask you for the file name. After loading your .s file, make it execute by typing: {ceylon} (~/cse401/pl0)(spim) run |
|
For more details on running spim or xspim, do the following :
1. Add /cse/courses/cse401/spim/man to your MANPATH
( Use setenv or export, whichever you shell allows )
2. Type :
{ceylon} (~cse401/pl0)% man spim3. The file /cse/courses/cse401/spim/info/spim.ps has all you want to know about spim.
Do look at this documentation at least once.
Its a great help!
|
401admin at cs.washington.edu