The P2 compiler

Pascal-P2 is available on sourceforge here:

The P2 compiler is one of a series of compiler/interpreters from the series:

Although I consider P2 fairly obsolete next to P4 and P5, I constructed a working copy of P2 and a few test programs. Here are the sources:

The Pascal-P2 compiler

The Pascal-P2 interpreter

It appears here with the permission of John Foust.

You will find a complete set of executables, test programs and documentation here:

Pascal-P2 was a rewrite of the Pascal-P1 compiler for the revised language Pascal released in 1974. The portability and several other issues were also addressed with the compiler/interpreter. As a result, P2 was the first widely used version of Pascal-P outside of Zurich.

Because the Pascal-P compiler/interpreter and the CDC 6000 compiler branched off early, you will also find that the P2 compiler matches the early versions of the CDC 6000 compilers better than later versions.

UCSD Pascal

When P2 got to University of California at San Diego and Professor Kenneth Bowles, they had vastly different ideas about what to do with it. Bowles figured that his students would profit more from a home computer version of the system than yet another compiler running on the huge power sucking mainframes the universities typically had (mostly because that was the kind of computer donated to them). He also decided that a typical 8080/Z80 computer did not have the horsepower to run native Pascal code. So he wrote an interpreter for a modified P2 object code, implemented it on the Z80 processor, and bootstrapped the thing as an interpreter. Later, UCSD Pascal was modified to include the all important "units" separate compilation facility, its own operating system, a companion Basic compiler/interpreter, and a series of graphical extensions for the language.

To be fair, there WERE in fact native Pascal compilers for the Z80. The earliest was Pascal/MT+, and by 1980 I had my first Z80 Pascal compiler running. However, UCSD Pascal had an enormous and even fanatical following, in a story that is almost a carbon copy of today's' Java and Java virtual machine. At one time, Western Digital (who used to make CPUs, not just disk drives) created a special version of the PDP-11 chipset they made just to execute the "P-machine" as native code (an experiment that fortunately ended when these machines were found not to be particularly faster than other, conventional chips with Pascal compilers).

UCSD Pascal introduced several extensions to the language that are still in use, including units and named file handling.

The best historical site available is John Foust's great "UCSD P-System Museum" here.

People reading the P2 sources expecting it to look like UCSD Pascal are going to be disappointed. Kenneth Bowles altered it beyond recognition for the UCSD system, and even the virtual machine code has very little resemblance to the P2 machine. In fact, Mr. Bowles probally deserves the credit for creating the first "byte code machine" which is sometimes credited to the Pascal-P series in general (which is very incorrect, since Pascal-P was not in fact byte oriented).

For more information contact: Scott A. Moore