Apple Pascal

These pages on Apple and Pascal are limited to Apple Pascal for the Apple ][ and III, where the UCSD p-System was used.

But there was much more Pascal history at Apple, as is show on the next article.

History of Apple and Pascal (DTC 1992)


Apple’s involvement with the Pascal language was extensive during the 1980 ‘s. From Apple’s introduction to Pascal on the Apple II computer in 1978, it has advanced to the powerful Macintosh 680×0 series Pascals of 1992.
Since 1988 Apple’s reliance on Pascal has been eclipsed by the emergence of C/C++ as Apple’s preferred system and application development language. Tho Pascal will have the support of a small but vocal minority at Apple, C/C++ will be the dominant development language for Apple and outsiders for the next decade.

A Brief History of Apple Computer’s Work with the Pascal Language
Written by David T. Craig 07 October 1992


This document provides a concise history of the work that Apple Computer has done with the Pascal computer language. This history was written so that this rather interesting bit of computer technology would be recorded for those with an interest in technical histories like this.
The author has never worked for Apple Computer, but has been involved with software development for Apple’s many computers since 1978 and has extensively used all of Apple’s Pascal implementations. As such, the facts contained herein are based upon personal memories and Apple technical documents and may be inaccurate. The author hopes that those in the know about Apple’s Pascal work will correct and extend upon this paper so that the history of Apple’s Pascals will be made complete.

See the Apple Pascal II page.
Apple first became involved with the Pascal language for its Apple ][ computer series around 1978. At this time Apple’s software development efforts were based upon the BASIC and 6502 assembly languages.
The key players in bringing Pascal to the Apple ][ were Bill Atkinson and Jef Raskin. Atkinson convinced Apple’s management that the Pascal language would be much better for Apple’s own software development activities than either BASIC or 6502 assembly. Atkinson and Raskin licensed the Pascal language and development system from the University of California at San Diego (UCSD) and began an internal Pascal development group.
Apple’s ][ Pascal system included a Pascal compiler, modal editor, 6502 assembler, a powerful filer, and several utility programs (e.g. program segment mapper). The system was controlled via a command line user interface.

The Apple ][ Pascal compiled to P-Code which was based upon byte codes and a stack architecture. This P-Code was interpreted by an interpreter written in 6502 assembly. 6502 assembly language routines could also be linked with P-Code programs. Identifiers in ][ Pascal were recognized only up to 8 characters, a painful limitation which Apple did not remove until its Macintosh MPW Pascal. Pascal’s memory use was restricted to 64k bytes due to the Apple ][ hardware architecture. ][ Pascal supported program modules called UNITs which could be either regular or shared (a. k. a. intrinsic). Units could be segmented so that they would reside in memory only when needed. ][ Pascal also supported a fairly sophisticated graphics unit called Turtle Graphics created by Atkinson.

Technical documentation for ][ Pascal was reasonably good and consisted of a language reference and an operating system manual.
Several major Apple ][ programs were developed in Apple ][ Pascal, including Apple’s Apple Presents the Apple and
PFS File by PFS Inc.
Apple produced several versions of Apple ][ Pascal: 1.0, 1.1, 1.2, 1.3. As of the middle 1980′ s Apple seems to have abandoned Pascal for the Apple ][. Current Apple ][ Pascal work is done via an Apple-developed Macintosh cross-development system called Macintosh Programmer’s Workshop.

See the Apple Pascal III page.
When Apple developed its Apple /// computer (1980 – 1985) it developed most of its software for this machine with Pascal.
Apple used the Apple ][ Pascal system to create the Apple /// Pascal system. As such, /// Pascal generated P-Codes for a stack-based architecture. The ///’s Pascal language syntax was extended (e. g. otherwise clause in case statements) and like Apple ][ Pascal also supported separate program units. Access to the ///’s native 6502-based operating system, SOS (Sophisticated Operating System, or Sara’s OS), also existed via a special Pascal unit called SOSIO. This OS unit also allowed programmers access to the ///’s larger memory, 256k bytes vs. 64k bytes for the ][ computer.
Apple produced several versions of Apple /// Pascal: 1. 0, 1. 1, 1. 2, 2.0. Version 2.0 of /// Pascal was unique in that it came with extensive technical documentation called the /// Pascal Workbench and consisted of around 1,000 pages. Version 2. 0’s Pascal compiler also produced a compilation listing consisting of the generated P-Code interleaved with the Pascal source code lines. /// Pascal also supported via a conditional compilation directive the compilation of Apple ][ Pascal programs and produced Apple ][ format code files.

Documentation for the /// Pascal system was excellent. This included a language manual, an operating system manual, and a very detailed runtime architecture manual which also listed all the P-Codes.
For /// Pascal Apple developed a very sophisticated floating-point implementation called SANE (Standard Apple Numeric Environment). SANE was based upon the IEEE floating-point standard. /// Pascal versions 1.0 and 1.1 supported only 4 byte REAL numbers, version 1.2 supported the higher quality 8 byte EXTENDED numbers. SANE went on to become the floating-point engine for Apple’s Lisa and Macintosh computers.
Most of Apple’s software for the /// was developed with the Pascal system. This included the System Utility Program and Backup ///.
The key players for Apple /// Pascal were Ira Rubin and Al Hoffmann.
Support for /// Pascal ended when Apple discontinued the /// computer in 1985. From this date onwards Apple seems to have ended its involvement with Pascal which generated P-Code, opting instead to deal fully with native code generators.

The 68000-based Lisa computer (1979 – 1985) was unique in that the majority of its system and application software was written in a powerful extended version of Pascal called Lisa Pascal. This software included the operating system (90^000 lines), the Workshop development environment (100,000 lines), 7 application programs (each around 50.000 lines [e.g. LisaWrite, LisaCalc]), and an avalanche of development support programs (e.g. mouse-based editor, telecommunications program, and Pascal language utilities).

Apple’s Lisa Pascal developments began from scratch for Apple when it licensed in 1981 a Motorola 68000 native code Pascal compiler from Silicon Valley Software in California. This compiler was based upon the older P4 compiler from Niklaus Wirth of ETH in Switzerland and consisted of two general passes. Pass 1 produced I-Code, a low-level representation of the high-level Pascal constructs. Pass 2, the code generator, converted the I-Codes to optimized 68000 object code. Apple even considered early in the Lisa’s development using a custom Apple processor which would execute P-Code directly, but the expense of developing such a chip was too much for Apple’s accountants and this project was dropped.

All Lisa development was done with the Lisa Workshop, a command line based development environment similar to Apple’s earlier ][ and /// Pascal systems. The Workshop provided an excellent development environment with its Pascal compiler, mouse-based editor, 68000 assembler, and an extensive collection of utility programs (e.g. Format, XRef, ProcNames). The Workshop supported other languages which included BASIC, COBOL, and C.

Apple produced several versions of Lisa Pascal: 1.0, 2.0, 3.0. Version 3. was the last version and supported the creation of intrinsic units which allowed a single copy of a unit to exist in the system and be used by several programs simultaneously. All versions supported language extensions such as otherwise clause in case statements, longint 32 bit integers, § operator for data addresses, data type coercion, and relaxed ordering of const/type/var sections. A lot of bit-based -functions were also
supported (e. g. BITAND to make bit bashing easier. Inline 68000 assembly code could also be used.

Like the Apple /// Pascal, Lisa Pascal also supported SANE, Apple’s IEEE floating-point implementation. In addition to SANE Apple developed a fairly comprehensive math package called MathLib.
Apple also developed an IEEE floating-point test program which attempted to ring out the bugs in SANE (Jerome Coonen of Apple wrote this test program and its associated test vectors).

Lisa Pascal was a superset of Apple’s older ][ and /// Pascals and, as such, was able to compile ][ and /// Pascal programs which did not make any ][ or /// system calls. Lisa Pascal could also produce a compilation listing complete with the Pascal source code interleaved with the generated 68000 assembly statements.

Apple also developed the Lisa QuickDraw (a. k. a. LisaGraf ) graphics library which formed the heart of what was called Lisa Technology. Though written in 68000 assembly^ Apple provided an extensive Pascal interface to this rather remarkable graphics environment (QuickDraw was later patented by Apple and Bi11 Atkinson. QuickDraw’s creator).

When Apple introduced the Macintosh computer in 1984 all Macintosh programming by Apple and others was done with Lisa Pascal and the Lisa Workshop. For this activity Apple created an extensive set of libraries containing the Macintosh toolbox interfaces. Many important Macintosh programs were written in Lisa Pascal, including MacPaint, MacWrite, MacDraw, and MacTerminal.

The key players behind Lisa Pascal were Ira Rubin and Al Hoffmann.
Apple provided extensive documentation for the Lisa Workshop and Lisa Pascal which included a language manual, an operating system manual, and a Workshop manual. Many internal memos were also released by Apple which described special features of Lisa Pascal.

Lisa Pascal was also used by Apple to develop the Lisa Clascal object-oriented language and the Clascal-based Toolkit class library.

Apple discontinued the Lisa in 1985 in favor of the Macintosh and when Apple’s native Macintosh development environment (MPW) became operational in 1986 Apple dropped support for Lisa Pascal and the Lisa Workshop. Therefore, Lisa Pascal lasted from 1981 to 1986, an eternity in the field of microcomputer languages.

Apple’s first foray into the world of object-oriented programming was with the Lisa Clascal (Classes + Pascal) language. Developed from 1983 to 1985 Clascal was an extension of Lisa Pascal which included several new keywords such as methods and subclass. The main concepts behind Clascal were derived from Simula and Smalltalk. Xerox PARC’s experimental object-oriented language.
In addition to Clascal Apple also developed an extensive set of class libraries which were collectively called the Lisa Toolkit. This class library allowed Lisa developers to create Lisa desktop applications (a. k. a. tools) in a fairly short time frame.

Though really used only internally by Apple for its own research efforts Clascal was made available to external developers but without any support by Apple (David Redhed of Seattle Washington created an independent Clascal/Toolkit support group called the Toolkit User’s Group [TUG], but this unfortunately did not last too long). Apple considered enhancing ClascaL but this Clascal-85 effort was extinguished by Apple’s work with Object Pascal for the Macintosh.
Several significant programs were developed with Clascal and the Toolkit including a calendar program, Apple’s Lisa-to-tlacintosh data conversion program, a desktop publishing program, and a fuzzy logic program.
The key player behind Clascal was Larry Tesler, one of the Lisa computer’s designers, and several former Xerox Smalltalk experts.

When Apple dropped all support for Clascal and the Toolkit it provided the Toolkit source code to the public, but the source code to the Clascal compiler was, alas, not made public.

Apple’s Pascal for the Macintosh computer (1984 – present) was a port of Apple’s earlier Lisa Pascal compiler. When Apple began development of the Macintosh (1982) Apple used Lisa Pascal and the Lisa Workshop for system software development.
With the introduction by Apple of the Macintosh Programmer’s Workshop (MPW) in 1986 Apple had a very professional development environment which from an extendability perspective surpassed the Lisa Workshop. MPW tools could be written that would be executed by selecting their names in a mouse-based window environment and performing the do-it command by pressing the Enter key on the keyboard (shades of Smalltalk). MPW provided a Pascal compiler 680×0 series assembler, an improved 680×0 linker, and a cornucopia of source code utility programs (e.g. PasMat, PasRef). Many languages were also supported, both from Apple and outsiders (e.g. a FORTRAN, COBOL, Modula-2).
MPW Pascal extended Lisa Pascal by supporting the newer Motorola 68000 processors, the 68020, 68030, and 68040. Also supported were the Motorola floating-point and memory management chips. Conditional compilation directives allowed MPW Pascal to support the direct generation of floating-point chip instructions so that floating-point speed could be as fast as possible. Identifiers in Pascal programs were recognized up to 63 characters, a limitation which existed in all prior Apple Pascals beginning with Apple ][ Pascal.
Several versions of MPW Pascal existed: 1.0, 2. 0, 3. 0, 3. 2. Version 3.2, the current 1992 version, was created to support development of System 7 programs and had several extensions to make this compiler support very large programs and support the calling of C functions with variable number of parameters.
MPW Pascal has improved upon the optimization of object code and includes such features as peep hole optimization and better register allocation of local and global constants.
Extensive documentation exists for MPW and MPW Pascal.
MPW Pascal was enhanced to support object-oriented programming and was renamed to Object Pascal. This extended version was used by Apple to develop the Macintosh class library called MacApp.
Apple also contracted with THINK Technologies who created an interactive Pascal learning environment that was called Macintosh Pascal (this interpreter was later turned into a real compiler).
Around 1988 Apple started to use the C and C++ languages for its own Internal software development. The ascendancy of C/C++ at Apple has initiated a marked descendancy of Pascal at Apple and by outside developers.

Object Pascal for the Macintosh was developed by Apple starting in 1985 to support more rapid and more standardized development of Macintosh programs. Available for only MPW, Object Pascal is a descendant of the Lisa Clascal compiler.
The key Apple player behind Object Pascal was Larry Tesler who recruited the help of Niklaus Wirth, the creator of Pascal, to clean up the syntax of Clascal.
Object Pascal was used to develop the extensive MacApp class library. This library was fully documented by Apple via several books and the source code for MacApp was provided to developers.
Object Pascal is being eclipsed by C/C++ at Apple and most outside developers are following Apple’s lead. The Object Pascal MacApp class library has been rewritten in C++.

Apple’s involvement with the Pascal language was extensive during the 1980 ‘s. From Apple’s introduction to Pascal on the Apple ][ computer in 1978, it has advanced to the powerful Macintosh 680×0 series Pascals of 1992.
Since 1988 Apple’s reliance on Pascal has been eclipsed by the emergence of C/C++ as Apple’s preferred system and application development language. Though Pascal will have the support of a small but vocal minority at Apple, C/C++ will be the dominant development language for Apple and outsiders for the next decade.

P5 Pascal

The next text and files are by Scott Moore, and
Local copy here.
He deserves all the honours of making this public available! The “I’ is Scott, not me!

The P5 compiler

Pascal-P5 is available on sourceforge here:
Local copy here.
The P5 compiler has existed for a long time as an idea. P4, the last of the Zurich series P-system compilers, left off before the ISO 7185 standard in 1982. It was not only not standard Pascal compliant, it also was only a subset, abeit a substantial one, of full revised Pascal. As an example, or "model" implementation of Pascal, it would have made sense to update the compiler to ISO 7185 status, and that was basically done as "A Model Implementation of Standard Pascal" [Welsh&Hay] before 1986. In fact, the project was designed to support the ISO 7185 project. However, there were a few reasons that a true P5, a straightforward update of the old p4, was a good idea. First, the source code of the "Model Implementation" is not generally available. Second, the "Model Implementation" is a complete scratch rewrite of the compiler, and shares virtually nothing in common with the original P4. This was important because several books, articles and online resources exist for the P4 compiler What I wanted for p5 was a compiler that both accepted ISO 7185 standard Pascal, and was also written in it. The compiler is an extended version of P4 and uses the same intermediate codes where possible. P5 now accepts the full ISO 7185 language, and also has been remade as a byte oriented machine, similar to what was done for both the UCSD compiler and the "Model Implementation". This is is the key to achieving a high efficiency implementation that runs with compact code. P5 also runs the PAT or Pascal Acceptance test, and also self compiles. P5 correctly runs the BSI, or British Standards Institute tests.

The meaning of P5

P5 is a very important milestone for Pascal. To understand why, it is a good idea to review why P4 was important. P4 was to accomplish:

  • Gave an example compiler for the Pascal language.
  • Gave a "model" of Pascal more complete than any description
    (i.e., the effect of any program construct could ultimately be determined
    by running it on P4).
  • Provided a bootstrapping kit to create new Pascal compilers.

To understand why P5 is important, you must understand that P4 didn’t completely accomplish the above goals. First of all, P4 was a subset of the full language. It was never designed to run the full language, only a minimal subset that could be ported to a new machine. The idea was to finish out the full language on the target machine.
Unfortunately, that meant there was not a concrete model of some of the more advanced (and hard to implement) features of full Pascal, for example interprocedural gotos, and procedure and function parameters. These and other features of Pascal left out of P4 were often left out of target compilers, and when they were implemented, they were implemented wrong. The other issue is that P4 was designed to be a minimal bootstrap implementation. If you examine P4, you will see that it makes little use of strings, and keeps them short. This is because it is very inefficient when it comes to storing them in memory. They are stored one character to a word (60 bits on the CDC 6000). Pascal has packing, but that is not implemented in P4. Finally, P4 is very much oriented to the CDC 6000 that it originated on. Everything is stored in 60 bit words, and there is a packing system designed to store two instructions per word.
The reason P4 had these limitations is that memory was very limited back in the 1970s, when P4 came about. Even on the CDC 6000. The authors of P4 worked hard to get P4 down in size and memory requirements so that it would self compile. By the time of the ISO 7185 standard, many people understood that P4 was limited for its purposes. The "Model Implementation of Standard Pascal" [Welsh & Hay] was the answer, and it contained a compiler for the full ISO 7185 Pascal language. Further, it implemented the interpreter as a byte oriented machine (sometimes called a "bytecode machine"). Unfortunately, it got sucked up into the BSI, who have effectively killed it (there appear to be no internet copies of it, and the BSI has not been forthcoming concerning it). Another issue with the "Model Implementation" (with apologies to Jim Welsh and Atholl Hay), is that the MI is written in the "self documented" form (avocated by D. E. Knuth and others) where the entire documentation exists in the same file, intermixed with the code. This is a beautiful method to present code as a finished product, but it tends to be fairly difficult to work on an change. Finally, the MI was a complete break with P4, and had nothing in common with it. This meant that MI used completely new methods and documentation, whereas P4 was already documented in the common media and well understood. P5 is both a break with the past and an embrace of it:

  • P5 is a straighforward extention of P4, and so most of the documentation
    and methods used with P4 are applicable to P5.
  • P5 completely implements ISO 7185.
  • P5 serves as a complete model for the implementation of Pascal.
  • P5 can be used to bootstrap both new compilers, and can efficiently
    self compile without limitations.
  • P5 is oriented toward byte machines, which is virtually all machines
    available today.
  • P5 can be used as a working interpreter, useful for running real programs.

The PAT and PRT

The PAT or Pascal acceptance test is a series of tests in one file that go through each feature of ISO 7185 Pascal. If a ISO 7185 Pascal implementation can compile and run this correctly, then it is substantially compliant with ISO 7185 Pascal.
There are two types of tests, the PAT and the PRT, or Pascal Rejection Test. The PAT test should compile and run correctly, and is a "positive" indication that the implementation compiles standard structures and gives standard results. The PRT is the opposite. It is designed to either fail to compile or generate runtime errors or both. It is a "negative" test that makes sure that the implementation rejects non-standard structures. The PAT only is represented here (for now).

Relationship to the BSI test suite

The BSI test suite [covered in Wichmann&Ciechanowicz] includes both positive and negative testing, and appeared in original version in the Pascal User’s Group. After a great deal of trouble I was able to OCR a copy of that test, which was published free and clear of restrictions. However, the both the test suite and bore copyright notices at one point, and both were given to the BSI (British Standards Institute) to keep and distribute. The BSI no longer distributes either, at any price, and whether they have kept it is also in doubt. In fact, recently I have been calling them about once a month to find out any information about the pair of programs. Both of them were created at universities outside of the BSI, and both were intended to be distributed, not locked in a vault to be eventually discarded. I don’t and won’t distrubute the BSI test without permission, and I don’t have access to the model compiler. Even with the BSI status of "openly published, but rights kept", I don’t feel comfortable putting it up on this site. However, because it was in fact openly published, I don’t feel that I, as an individual, am unable to run the tests, either. Now, the reason that all of this matters is that with P5, we have effectively replaced the material imprisoned by the BSI. P5 upgrades P4, which never bore a copyright, was public domain, and was distributed openly. I put my own work into upgrading P4 into P5, but I donate that work back to the public domain. As P4 was, P5 is free of copyright and charges. Use as you see fit. The PAT was created entirely by me and is original work. However, I also donate this to public domain. It was created back in the early 1990’s, and used to validate both mine and other Pascal compilers. The PAT effectively replaces the positive testing side of the BSI. I also intend to create a negative test, the PRT, and also make that public domain. Further, the PAT and PRT form a collection point for tests, including test that were made in reaction to the failures seen while running the BSI tests. In other words, if the BSI test found a failure, then an equivalent test was added to the PAT (not copied from the BSI!). This is a work in progress, so not all failure points have yet been addressed. Thus, the PAT and PRT are designed to be full replacements for the BSI tests. Format and working of the PAT The PAT is designed to execute a small amount of code, then print the results. Each "test point" tests one feature of ISO 7185 Pascal,and is numbered according to type and sequence. Here is an example from the test:

  write('Control6: ');
  if true then write('yes') else write('no');
  writeln(' s/b yes');

This prints:

Control 6: yes s/b yes

So you see the number and type of the test, control structures number 6, the result, ‘yes’, and finally what the result should be. The PAT is designed to be verified manually, that is, you read it and check that the printed results equal the "should be" collumn. The PAT can be easily automated for regression purposes by redirecting the output to a file, then comparing a saved "gold" version of the result file to the current file.

Self compile

P5 is capable compiling itself. This takes different steps for each of the sections, pcom and pint. The resulting intermediate files are listed in the files section below.


I was able to get pcom.pas to self compile. This means to compile and run pcom.pas, then execute it in the simulator, pint. Then it is fed its own source, and compiles itself into intermediate code. Then this is compared to the same intermediate code for pcom as output by the regular compiler. Its a good self check, and in fact found a few bugs.
The Windows batch file to control a self compile and check is:
What does it mean to self compile? For pcom, not much. Since it does not execute itself (pint does that), it is simply operating on the interpreter, and happens to be compiling a copy of itself.

Changes required


Pint is more interesting to self compile, since it is running (being interpreted) on a copy of itself. Unlike the pcom self compile, pint can run a copy of itself running a copy of itself, etc., to any depth. Of course, each time the interpreter runs on itself, it slows down orders of magnitude, so it does not take many levels to make it virtually impossible to run to completion. Ran a copy of pint running on itself, then interpreting a copy of iso7185pat. The result of the iso7185pat is then compared to the "gold" standard file. As with pcom, pint will not self compile without modification. It has the same issue with predefined header files. Also, pint cannot run on itself unless its storage requirements are reduced. For example, if the "store" array, the byte array that is used to contain the program, constants and variables, is 1 megabyte in length, the copy of pint that is hosted on pint must have a 1 megabyte store minus all of the overhead associated with pint itself. The windows batch file required to self compile pint is:
As a result, these are the changes required in pint:

{ !!! Need to use the small size memory to self compile, otherwise, by 
  definition, pint cannot fit into its own memory. }
maxstr = 2000000; { maximum size of addressing for program/var }
 {maxstr = 200000;} { maximum size of addressing for program/var }

{ !!! remove this next statement for self compile }
prd,prr : text;(*prd for read only, prr for write only *)

{ !!! remove this next statement for self compile }

{ !!! remove this next statement for self compile }

All these changes were made in the file pintm.pas.
Pint also has to change the way it takes in input files. It cannot read the intermediate from the input file, because that is reserved for the program to be run. Instead, it reads the intermediate from the "prd" header file. The interpreted program can also use the same prd file. The solution is to "stack up" the intermediate files. The intermediate for pint itself appears first, followed by the file that is to run under that (iso7185pat). It works because the intermediate has a command that signals the end of the intermediate file, "q". The copy of pint that is reading the intermediate code for pint
stops, then the interpreted copy of pint starts and reads in the other part of the file. This could, in fact, go to any depth. All of the source code changes from pint.pas to pintm.pas are automated in cpints.bat.

Self compiled files and sizes

The resulting sizes of the self compiled files are:

Storage areas occupied
Program             0-114657( 114658)
Stack/Heap   114658-1987994 (1873337)
Constants   1987995-2000000 (  12005)

Storage areas occupied
Program             0- 56194 ( 56195)
Stack/Heap    56195-1993985 (1937791)
Constants     1993986-2000000 ( 6014)

Files for the P5 system

Pascal-P5 is entirely hosted on sourceforge now. Please see the site for all sources:
Local copy here.
This lets you access my development link for Pascal-P5. You can use this to:

  • download the entire source tree.
  • browse individual files
  • retrieve old versions
  • File bugs or requests
  • Track the status of or find existing problems/issues
  • Become a co-developer

And much more.
For versioned files (releases) see the files area. The current version is always archived as pascal-p5.tar.gz. The current and previous versions are named as:

pascal-p5_<major version>_<minor version>

That is, each time I create a new version, I make a copy of it using the naming system above. This allows each version to be recovered and used. To get a current development copy of Pascal-P5 source, simply have GIT installed on your system, and execute the following in the directory where you wish to install P5: git clone ssh:// pascalp5-code This will get the entire P5 file tree and place it into the target directory "p5".

A note about versioning

My common practice is to "bump" the version numer after any changes are made to a certified release. The idea is that the new version number will be the version of the next release to come. This of course can cause confusion. However, the rule, is: if it is not in the above release list, then it is a development version.

Getting started

For all versions see the readme.txt file in the root directory.

Compiling and using P5

The P5 compiler/assembler is much easier than P4 in one respect. There are no limitations to remember verses ISO 7185 Pascal. If it is legal Standard Pascal, it will compile and run.

To run P5, use the following format:

pcom < source.pas
pint program.out

All files must be specified. This is what the batch file p5.bat given above does.

What is.. and is not in P5

While upgrading P4 to P5, I specifically tried to avoid any temptation to "improve" the code, such as add functions or features, or reformat the code to be more presentable, etc. There is a time and place for that. I simply wanted P5 to be a full language compiler for Pascal, instead of a subset compiler. The one exception I allowed for is the addition of a routine that dumps all of the error codes that were used in the source compile along with their text equivalents. I have found this to be a great improvement on trying to search the various documents for what error code means what. Of course, virtually all implementations improve on the original Pascal, including the original CDC 6000 compiler. The extensions consist of a combination of features best left defined to a particular implementation, and also usablity extentions to Pascal in general. There’s a lot more that can be done with P5. However, I have left that for the P6 project. P6 is the next step for the P-series, and includes a series of extentions to the base ISO 7185 language.

For more information contact: Scott A. Moore

Stanford Pascal 360

The Stanford Pascal 360 (1979 version) is a modified version of the P2 Compiler, and except for a few minor extensions, processes the same language. The compiler itself is a 5000 lines Pascal program that translates to P-code. A post processor then translates P-code to IBM assembly code.

The later Stanford Pascal compiler is an offspring of the original Pascal P4 compiler.

A compiler based on the Pascal-P4 compiler, which created native binaries, was released for the IBM System/370 mainframe computer
by the Australian Atomic Energy Commission; it was called the “AAEC Pascal Compiler” after the abbreviation of the name of the Commission.

The AAEC compiler later became the Stanford Pascal compiler (in 1979 ca.), and later again, it was maintained by the McGill university in Montreal, Canada (from 1982 on).

New Stanford Pascal:

CS-TR-79-731.pdf Stanford Pascal Verifier User Manual, March 1979
October 1974 Stanford Pascal/360 Implementation Guide, contains source of compiler (4665 lines)
Stanford1979.pdf many original sources (and later improved versions of Stanford Pascal, part of the Bernd Oppolzer initiative.

PDP-11 Pascal compiler

Archive with the DECUS DEC PDP-11 Pascal compiler, including sources.

This compiler is a descendent of the ZürichPascal compilers.

            DECUS Pascal for PDP-11

	          Version 6.3,  November 1985


This compiler implements the Pascal programming language on PDP-11s
running RSX-11 and on other systems that can run RSX tasks (eg. RSTS,

The main features of this Pascal are:
  - can optionally compile programs to use any arithmetic hardware
  - useful language extensions: default case, loop statement, variable
    length string parameters, substring parameters, structured function
    results, boundless array parameters, and more
  - enhanced I/O facilities for creating and accessing files of
    various types
  - standard file for terminal I/O
  - separate compilation of procedures/functions
  - linkage to external FORTRAN or MACRO routines
  - source "include" facility
  - development aids: statement trace, statement execution profiler,
    conditional compilation
  - high level interactive symbolic debugger and symbolic dump
  - all source and tools provided for maintaining the compiler and
    runtime library (compiler can only be re-compiled on RSX-11).

This release introduces several minor corrections and enhancements.
In particular it now runs on the latest versions of RSTS and RSX.

Several deviations from the ISO/ANSI Pascal Standard.  (Conformance
report in user manual.)

Model Helicopter Control

Automatic Control of Model Helicopter

In 1995 Wirth joined a project undertaken at the Institute of Automatic Control and Measurement. The goal was the development of a system to allow a model helicopter to fly autonomously a preprogrammed path. Wirth designed an on-board computer system with a Strong-ARM processor at its core. Aside from the hardware, he also programmed various software tools, including an Oberon subset compiler with additional features for real-time programming. The computer board was built by I. Noack.
The resulting computer system, called Olga, made use of experience with programmable gate arrays, and used the novel Xilinx-Algotronix 6200 fine-grained FPGA for the generation and sensing of pulse-width modulated signals to control the servos. Furthermore, the computer was connected to a compass, a global positioning system (GPS), and a data link via several standard RS-232 interfaces. This system resulted in a drastic reduction of weight and power consumption, and an increase in computing performance compared to the one used before, inspite of the fact that floating-point arithmetic was to be programmed based on integer arithmetic.

The helicopter carrying Olga weighs about 15 kg and is powered by a 35ccm engine. Wirth pushed for a second project based on a downsized helicopter model with a weight of less than 5 kg and a conventional 10ccm engine. This was realized with a considerably smaller computer board, but the same Strong-ARM core and software base. The large FPGA was replaced by several small PLDs. This project, Horla, was confined to the more modest goal of using the computer only to stabilize the inherently unstable craft, while position, speed and direction would remain under remote control by the pilot.

Both projects collected in a remarkable way the various techniques and tools on which Wirth had worked during the past decade: Compiler, operating system, programmable devices (FPGA, PLD) and their design tools including the language Lola, and circuit design in general. Both projects were successful, although only after several years of effort – and patience.


Helicopter Flight Control Report 1 The Hardware Core
Helicopter Flight Control Report 2 The Programming Language Oberon SA
Helicopter Flight Control Report 3 The Software Core
Helicopter Flight Control Report 6 The Oberon Compiler for the Strong-ARM Processor
Software for Model Helicopter Flight Control
An Oberon Compiler for the ARM Processor, 2007
/Interrupts and Traps in Oberon-ARM, 2008
SET: A neglected data type, and its compilation for the ARM, 2007
Differences between Revised Oberon and Oberon
The Programming Language Oberon Revision 1.10.2013 / 3.5.2016
Oberon-07 (Revised Oberon) (Oberon at a glance), 2013
Porting the Oberon Compiler from Oberon to Oberon-07, 2007


Lola was designed as a simple, easily learnable hardware description language for describing synchronous, digital circuits. In addition to its use in a digital design course for second year computer science students at ETH Zürich, the Institute for Computer Systems uses it as a hardware description language for describing hardware designs in general and coprocessor applications in particular.
The purpose of Lola is to statically describe the structure and functionality of hardware components and of the connections between them. A Lola text is composed of declarations and statements. It describes the hardware on the gate level in the form of signal assignments. Signals are combined using operators and assigned to other signals. Signals and the respective assignments can be grouped together into types. An instance of a type is a hardware component. Types can be composed of instances of other types, thereby supporting a hierarchical design style and they can be generic (e.g. parametrizable with the word-width of a circuit).

The Lola System is a toolbox consisting of various modules whose commands serve to specify, implement, and test digital circuits. These notes explain its structure to the user of Lola and to the implementer of additional tools. The system’s base is a module containing the definition of the central data structure used to describe digital circuits. Its name is LSB (Lola System Base). Typically, such a data structure is generated from a Lola text by the compiler, and thereafter used as argument for further processing steps, such as simplification, analysis, comparison, simulation, and layout generation. Fig. 1 gives an overview of the described components and their interdependence.

Lola-2: A Logic Description Language, Language description

Lola-2: Translating from Lola to Verilog

Tools for Digital Circuit Design using FPGAs
H Eberle and S. Gehring and S. Ludwig and N.Wirth,  1994
This collection of five papers describes concept and facilities of a  system to aid in the design of digital circuits. It is being used in classes and laboratories for circuit design, and also for the development of prototype circuits in research projects. The collection comprises the report on the Lola language for specifying digital circuits, an introduction to field programmable gate arrays (FPGA) and the Atmel 6000 architecture, the user manual of the CL layout editor, the user manual of the CL design checker, and the description of two FPGA extension boards for Ceres-3.

A Laboratory for a Digital Design Course Using FPGAs
Stephan Gehring Stefan Ludwig Niklaus Wirth, 1994
In our digital design laboratory we have replaced the traditional wired circuit modules by workstations equipped with an extension board containing a single FPGA. This hardware is supplemented with a set of software tools consisting of a compiler for the circuit specification language Lola, a graphical layout editor for design entry, and a checker to verify conformity of a layout with its specification in Lola. The new laboratory has been used with considerable success in digital design courses for computer science students. Not only is this solution much cheaper than collections of modules to be wired, but it also allows for more substantial and challenging exercises.

Lola Compiler for Project Oberon, 2013 Edition

Lola Definition of RISC5 Computer

FPGA-related Work

Hardware Design with Field Programmable Gate Arrays (FPGAs), 1990-1999
Similarity and difference between hardware and software design always had intreagued Wirth as a topic. With the emergence of programmable logic devices, the gap between the two fields narrowed. A project to familiarize a team with the new possibilities was established, and research in design methods using the new devices was started. It led to a set of design tools, including a specification language (Debora, B. Heeb), its compiler with several “back ends” for printed circuits boards, PLDs, and FPGAs. The usefulness of these tools was demonstrated by applying them in the construction of a workstation (Chamaeleon, also Ceres-3). The construction process starting from a textual specification and ending with a board layout and PLD programs was automated, and it required almost no manual intervention.
Wirth realized early, that FPGAs would be particularly useful as a field for experimentation in learning digital circuit design, replacing expensive, pluggable circuit modules by programmable cells. He equipped 25 Ceres-3 workstations in a student laboratory with an FPGA and uses them intensively in a digital design class. Along with a new project in tool design went the formulation of his language Lola, specifically tailored to the need of teaching in a systematic manner, dispensing with the myriads of side-issues inherent in commercial HDLs. The tool set consists of a compiler converting the program (circuit) text into an abstract data structure suitable for further processing, an editor for constructing circuits implemented by the FPGA, i.e. for generating a layout, and a checker comparing the specification in Lola with the layout.

The TRM: Experiments in Computer System Design
The Design of a RISC Architecture and its Implementation with an FPGA
– [RISC0.v]
– [RISC0Top.v]
– [PROM.v]
– [DRAM.v]
– [Multiplier.v]
– [Multiplier1.v]
– [Divider.v]
– [RISC0.ucf]
– [RS232R.v]
– [RS232T.v]
RISC Architecture
Three Counters


The Language PICL and its Implementation, Niklaus Wirth, 20. Sept. 2007

PICL is a small, experimental language for the PIC single-chip microcomputer. The class of computers which PIC represents is characterized by a wordlength of 8, a small set of simple instructions, a small memory of at most 1K cells for data and equally much for the program, and by integrated ports for input and output. They are typically used for small programs for control or data acquisition systems, also called embedded systems. Their programs are mostly permanent and do not change.
All these factors call for programming with utmost economy. The general belief is that therefore programming in a high-level language is out of the question. Engineers wish to be in total control of a program, and therefore shy away from complex languages and compiler generating code that often is unpredictable and/or obscure.
We much sympathize with this reservation and precaution, particularly in view of the overwhelming size and complexity of common languages and their compilers. We therefore decided to investigate, whether or not a language could be designed in such a way that the reservations would be unjustified, and the language would indeed be beneficial for programmers even of tiny systems.
We chose the PIC processor, because it is widely used, features the typical limitations of such single-chip systems, and seems to have been designed without consideration of high-level language application. The experiment therefore appeared as a challenge to both language design and implementation.
The requirements for such a language were that it should be small and regular, structured and not verbose, yet reflecting the characteristics of the underlying processor.

A Microcontroller System for Experimentation, description, parts of which are published on this page.
PICL: A Programming Language for the Microcontroller PIC, EBNF
The Language PICL and its Implementation, Code generation.
PICL Scanner, Oberon source
PICL Parser, Code Generator, Oberon source

The Language PICL
The language is concisely defined in a separate report. Here we merely point out its particular characteristics which distinguish it from conventional languages. Like conventional languages, however, it consist of constant, variable, and procedure declarations, followed by statements of various forms. The simplest forms, again like in conventional languages, are the assignment and the procedure call. Assignments consist of a destination variable and an expression. The latter is restricted to be a variable, a constant, or an operator and its operand pair. No concatenation of operations and no parentheses are provided. This is in due consideration of the PIC’s simple facilities and ALU architecture. Examples can be found in the section on code patterns below. Conditional and repetitive statements are given the modern forms suggested by E. W. Dijkstra. They may appear as somewhat cryptic. However, given the small sizes of programs, this seemed to be appropriate.

Conditional statements have the form shown at the left and explained in terms of conventional notation to the right.

[cond -> StatSeq]                     IF cond THEN Statseq END
[cond -> StatSeq0|* StatSeq1 ]        IF cond THEN Statseq0 ELSE StatSeq1 END
[cond0 -> StatSeq0|cond1 -> StatSeq1] IF cond0 THEN Statseq0 ELSIF cond1 THEN StatSeq1END

Repetitive statements have the form:

{cond -> StatSeq}                     WHILE cond DO Statseq END
{cond0 -> StatSeq0|cond1 -> StatSeq1} WHILE cond0 DO Statseq0 ELSIF cond1 DO StatSeq1END

There is also the special case mirroring a restricted form of for statement. Details will be
explained in the section on code patterns below.

{| ident, xpression -> StatSeq}

The PICL Compiler
The compiler consists of two modules, the scanner, and the parser and code generator. The scanner recognizes symbols in the source text. The parser uses the straight-forward method of syntax analysis by recursive descent. It maintains a linear list of declared identifiers for constants, variables, and procedures.


MODULE RepeatStat;
  INT x, y;
  REPEAT x := x + 10; y := y - 1 UNTIL y = 0;
END RepeatStat.

0 0000300A MOVLW 10
1 0000078C ADDWF 1 12 x := x + 10
2 00003001 MOVLW 1
3 0000028D SUBWF 1 13
4 0000080D MOVFW 0 13 y := y - 1
5 00001D03 BTFSS 2 3 = 0 ?
6 00002800 GOTO 0
7 00000B8D DECFSZ 1 13 y := y – 1; = 0?
8 00002807 GOTO 7


The following procedures serve for sending and receiving a byte. Transmission occurs over a 3-wire connection, using the conventional hand-shake protocol. Port A.3 is an output. It serves for signaling a request to receive a bit. Port B.6 is an input and serves for transmittithe data. B.7 is usually in the receiving mode and switched to output only when a byte is to be sent. In the idle state, both request and acknowledge signals are high (1).

  INT n;
BEGIN ?B.6;                     wait for ack = 1
  !S.5; !~B.7; !~S.5; n := 8;   switch B.7 to output
    IFx.0 -> !B.7 ELSE !~B.7 END; apply data
    !~A.3; issue request
    ?~B.6; wait for ack
    !A.3; ROR x; reset req, shift data
    ?B.6; DEC n wait for ack reset
  UNTIL n = 0;
  !S.5; !B.7;!~S.5 reset B.7 to input
END Send;

  INT n;
BEGIN d := 0; n := 8; result to global vaiable d
    ?~B.6; ROR d;     wait for req
    IF B.7 THEN !d.7 ELSE !~d.7 END ; sense data
    !~A.3;           issue ack
    ?B.6;            wait for req reset
    !A.3; DEC n      reset ack
  UNTIL n = 0
END Receive;

Another version of the same procedures also uses three lines. But it is asymmetric: There is a master and a slave. The clock is always delivered by the master on B.6 independent of the direction of the data transmission on A3 and B7.

When sending, the data is applied to A.3, when receiving, the data is on B.7. The advantage of this scheme is that no line ever switches its direction, the disadvantage is its dependence on the relative speeds of the two partners. The clock must be sufficiently slow so that the slave may follow. There is no acknowledgement.

Master                              Slave
PROCEDURE Send(INT x);              PROCEDURE Receive;
  INT n;                              INT n;
BEGIN n := 8;                       BEGIN d := 0; n := 8;  result to global vaiable d
  REPEAT                              REPEAT ?~B.6; !>d;   wait for clock low
    IF x.0 THEN !A.3 ELSE !~A.3 END;    IF B.7 THEN !d.7 ELSE ~d.7 END; sense data
    !~B.6; !>x; !B.6; DEC n             ?B.6; DEC n        wait for clock high
  UNTIL n = 0                         UNTIL n = 0
END Send;                           END Receive;

PROCEDURE Receive;                  PROCEDURE Send(INT x);
  INT n;                              INT n;
BEGIN d := 0; n := 8;               BEGIN n := 8;
  REPEAT !~B.6; ROR d;                REPEAT ?~B.6;        wait for clock low
    IF B.7 THEN !d.7 ELSE ~d.7 END;     IF x.0 THEN !A.3 ELSE !~A.3 END; apply data
    !B.6; DEC n                         ROR x ?B.6; DEC n  wait for clock high
  UNTIL n = 0                         UNTIL n = 0
END Receive;                        END Send;

The motivation behind this experiment in language design and implementation had been thequestion: Are high-level languages truly inappropriate for very small computers? The answer is: Not really, if the language is designed in consideration of the stringent limitations. I justify my answer out of the experience made in using the language for some small sample programs. The corresponding assembler code is rather long, and it is not readily understandable. Convincing oneself of its correctness is rather tedious (and itself error-prone). In the new notation, it is not easy either, but definitely easier due to the structure of the text.
In order to let the regularity of this notation stand out as its main characteristic, completeness was sacrificed, that is, a few of the PIC’s facilities were left out. For example, indirect addressing, or adding multiple-byte values (adding with carry). Corresponding constructs can easily be added.
One might complain that this notation is rather cryptic too, almost like assembler code. However, the command (!) and query (?) facilities are compact and useful, not just cryptic. Programs for computers with 64 bytes of data and 2K of program storage are inherently short; their descriptions should therefore not be longwinded. After my initial doubts, the new notation appears as a definite improvement over conventional assembler code.
The compiler was written in the language Oberon. It consists of a scanner and a parser module of 2 and 4 pages of source code respectively (including the routines for loading and verifying the generated code into the PIC’s ROM). The parser uses the time-honored principle of top-down, recursive descent. Parsing and code generation occur in a single pass.



Euler is a programming language created by Niklaus Wirth and Helmut Weber, conceived as an extension and generalization of ALGOL 60. The designers’ goal was to create a language which was simpler, and yet more flexible, than ALGOL 60 that was a useful programming language processed with reasonable efficiency that can be defined with rigorous formality. Available sources indicate that Euler was operational by 1965.

Euler employs a general type concept. In Euler, arrays, procedures, and switches are not quantities which are declared and named by identifiers: they are not (as opposed to ALGOL) quantities which are on the same level as variables, rather, these quantities are on the level of numeric and boolean constants. Thus, besides the traditional numeric and logical constants, Euler introduces the following additional types:

  • reference
  • label
  • symbol
  • list (array)
  • procedure
  • undefined

All constants can be assigned to variables, which have the same form as in ALGOL, but for which no fixed types are specified: Euler is a dynamically typed programming language. Furthermore, a procedure can produce a value of any type when executed, and this type can vary from one call of the procedure to the next. Similarly, the elements of a list can have values of any type and these can be different from element to element within the list. So, when the list elements are labels, a switch is obtained. If the elements are procedures, a procedure list is obtained (which is not available in ALGOL 60). If the elements are lists themselves, then a general tree structure is obtained. Euler provides general type-test and type-conversion operators.

Sample program

   CV ~ LB;
   CV ~ CV + STEP;
   GOTO K;
   L: 0

   L ~ B; T ~ LIST L[1];
   FOR (@I, 1, 1, L[1], LQ T[I] ~ F RQ);

   A ~ ();
   FOR (@T, 1, 1, 4, LQ BEGIN A ~ A &amp;amp;amp; (T); OUT MAKE(@A,T) END RQ)


EULER Formal Definition, Niklaus Wirth
Source of EULER, 1965
Syntax Processor, Nikluas Wirth, 1964
PDP10 EULER handbook
EULER An Experiment in Language Definiton, Thomas W. Cristopher

See also for an Icon implementation of an Euler compiler/interpreter


 VARDECL           NEW IDENT*                                                001
 FORDECL           FORMAL IDENT*                                             002
 LABDECL           LABEL IDENT*                                              003
 VAR-              IDENT*                                                    004
 VAR-              VAR- [ EXPR ]                                             005
 VAR-              VAR- .                                                    006
 VAR               VAR-                                                      007
 LOGVAL            TRUE                                                      010
 LOGVAL            FALSE                                                     011
 DIGIT             0                                                         012
 DIGIT             1                                                         013
 DIGIT             2                                                         014
 DIGIT             3                                                         015
 DIGIT             4                                                         016
 DIGIT             5                                                         017
 DIGIT             6                                                         020
 DIGIT             7                                                         021
 DIGIT             8                                                         022
 DIGIT             9                                                         023
 INTEGER-          DIGIT                                                     024
 INTEGER-          INTEGER- DIGIT                                            025
 INTEGER*          INTEGER-                                                  026
 REAL*             INTEGER* . INTEGER*                                       027
 REAL*             INTEGER*                                                  030
 NUMBER            REAL*                                                     031
 NUMBER            REAL* TEN INTEGER*                                        032
 NUMBER            REAL* TEN # INTEGER*                                      033
 NUMBER            TEN INTEGER*                                              034
 NUMBER            TEN # INTEGER*                                            035
 REFERENC          @ VAR                                                     036
 LISTHEAD          LISTHEAD EXPR ,                                           037
 LISTHEAD          (                                                         040
 LIST*             LISTHEAD EXPR )                                           041
 LIST*             LISTHEAD )                                                042
 PROCHEAD          PROCHEAD FORDECL ;                                        043
 PROCHEAD          LQ                                                        044
 PROCDEF           PROCHEAD EXPR RQ                                          045
 PRIMARY           VAR                                                       046
 PRIMARY           VAR LIST*                                                 047
 PRIMARY           LOGVAL                                                    050
 PRIMARY           NUMBER                                                    051
 PRIMARY           SYMBOL*                                                   052
 PRIMARY           REFERENC                                                  053
 PRIMARY           LIST*                                                     054
 PRIMARY           TAIL PRIMARY                                              055
 PRIMARY           PROCDEF                                                   056
 PRIMARY           UNDEFINE                                                  057
 PRIMARY           [ EXPR ]                                                  060
 PRIMARY           IN                                                        061
 PRIMARY           ISB VAR                                                   062
 PRIMARY           ISN VAR                                                   063
 PRIMARY           ISR VAR                                                   064
 PRIMARY           ISL VAR                                                   065
 PRIMARY           ISLI VAR                                                  066
 PRIMARY           ISY VAR                                                   067
 PRIMARY           ISP VAR                                                   070
 PRIMARY           ISU VAR                                                   071
 PRIMARY           ABS PRIMARY                                               072
 PRIMARY           LENGTH VAR                                                073
 PRIMARY           INTEGER PRIMARY                                           074
 PRIMARY           REAL PRIMARY                                              075
 PRIMARY           LOGICAL PRIMARY                                           076
 PRIMARY           LIST PRIMARY                                              077
 FACTOR-           PRIMARY                                                   100
 FACTOR-           FACTOR- * PRIMARY                                         101
 FACTOR            FACTOR-                                                   102
 TERM-             FACTOR                                                    103
 TERM-             TERM- | FACTOR                                            104
 TERM-             TERM- / FACTOR                                            105
 TERM-             TERM- % FACTOR                                            106
 TERM-             TERM- MOD FACTOR                                          107
 TERM              TERM-                                                     110
 SUM-              TERM                                                      111
 SUM-              + TERM                                                    112
 SUM-              - TERM                                                    113
 SUM-              SUM- + TERM                                               114
 SUM-              SUM- - TERM                                               115
 SUM               SUM-                                                      116
 CHOICE-           SUM                                                       117
 CHOICE-           CHOICE- MIN SUM                                           120
 CHOICE-           CHOICE- MAX SUM                                           121
 CHOICE            CHOICE-                                                   122
 RELATION          CHOICE                                                    123
 RELATION          CHOICE = CHOICE                                           124
 RELATION          CHOICE ! CHOICE                                           125
 RELATION          CHOICE &amp;amp;lt; CHOICE                                           126
 RELATION          CHOICE { CHOICE                                           127
 RELATION          CHOICE } CHOICE                                           130
 RELATION          CHOICE &amp;amp;gt; CHOICE                                           131
 NEGATION          RELATION                                                  132
 NEGATION          NOT RELATION                                              133
 CONJHEAD          NEGATION AND                                              134
 CONJ-             CONJHEAD CONJ-                                            135
 CONJ-             NEGATION                                                  136
 CONJ              CONJ-                                                     137
 DISJHEAD          CONJ OR                                                   140
 DISJ              DISJHEAD DISJ                                             141
 DISJ              CONJ                                                      142
 CATENA            CATENA &amp;amp;amp; PRIMARY                                          143
 CATENA            DISJ                                                      144
 TRUEPART          EXPR ELSE                                                 145
 IFCLAUSE          IF EXPR THEN                                              146
 EXPR-             BLOCK                                                     147
 EXPR-             IFCLAUSE TRUEPART EXPR-                                   150
 EXPR-             VAR ~ EXPR-                                               151
 EXPR-             GOTO PRIMARY                                              152
 EXPR-             OUT EXPR-                                                 153
 EXPR-             CATENA                                                    154
 EXPR              EXPR-                                                     155
 STAT-             LABDEF STAT-                                              156
 STAT-             EXPR                                                      157
 STAT              STAT-                                                     160
 LABDEF            IDENT* :                                                  161
 BLOKHEAD          BEGIN                                                     162
 BLOKHEAD          BLOKHEAD VARDECL ;                                        163
 BLOKHEAD          BLOKHEAD LABDECL ;                                        164
 BLOKBODY          BLOKHEAD                                                  165
 BLOKBODY          BLOKBODY STAT ;                                           166
 BLOCK             BLOKBODY STAT END                                         167
 PROGRAM           $ BLOCK $                                                 170


PL360 (or PL/360) is a system programming language designed by Niklaus Wirth and written by Niklaus Wirth, Joseph W. Wells, Jr., and Edwin Satterthwaite, Jr. for the IBM System/360 computer at Stanford University. A description of PL360 was published in early 1968.

Niklaus Wirth in 1966 wanted to have a compiler written for his new Algol W language and the choices of programming language with which to write the compiler were FORTRAN and assembler language Wirth set aside the Algol W project temporarily and developed a programming language which was specifically designed for writing system-level software on an IBM 360 system. This systems programming language, the very first systems programming language other than assembler language, came to be known as PL360 (the name is sometimes written as PL/360 although it seems pretty clear that Wirth called it PL360 – I’m not 100% sure of this so please correct me if I’m wrong).

In practical terms, PL360 isn’t much more than an assembly language dressed up in fancy clothes (strictly speaking, it’s actually called a structured assembly language). Although a reasonable set of operators are defined, expression evaluation is strictly left to right and the programmer is responsible for managing the use of the machine registers and most aspects of memory management. In fact, it really wasn’t possible to write a PL360 program without quite intimate knowledge of the System/360 architecture.

The result is a language which requires considerable care and attention on the part of the programmer. Although friendlier than an actual assembler language, the inattentive programmer is provided with plenty of potential learning opportunities (i.e. pitfalls). For example, consider the following two statements:

R1 := R1 + R2;
R1 := R2 + R1;

Although these may appear to be equivalent, they are actually VERY different. The first statement adds machine register R2 to the contents of register R1 and stores the result in R1 (i.e. it adds R1 and R2 together and stores the result in R1). The second statement is actually equivalent to:
R1 := R2; R1 := R1 + R1;
i.e. it effectively computes 2*R2 and stores the result in R1.
PL360 ends up looking pretty sad if it is considered as a high-level programming language. On the other hand, if viewed as a mid to low-level language (i.e. an assembler language in fancy clothes) then it was actually quite respectable for the era. In fact, since the goal was to create a language which could be used to do systems programming, the necessity to understand the underlying architecture in detail was arguably a language feature rather than a failing.

By 1968, a compiler had been written for the PL360 language and Wirth was able to get on with the task of getting an Algol W compiler written. The ability to write systems programming level software using reasonably conventional looking statements and expressions turned out to be quite useful and PL360 went on to be used for a variety of projects.

PL/360 is a one pass compiler with a syntax similar to Algol that provides facilities for specifying exact machine language instructions and registers similar to assembly language, but also provides features commonly found in high-level languages, such as complex arithmetic expressions and control structures. Wirth used PL360 to create Algol W.

Data types are:

  • Byte or character – a single byte.
  • Short integer – 2 bytes, interpreted as an integer in two’s complement binary notation.
  • Integer or logical – 4 bytes, interpreted as an integer in two’s complement binary notation.
  • Real – 4 bytes, interpreted as a base-16 short floating-point number.
  • Long real – 8 bytes, interpreted as a base-16 long floating-point number.
  • Registers can contain integer, real, or long real.
    • Individual System/360 instructions can be generated inline using the PL360 “function statement” that defined an instruction by format and operation code. Function arguments were assigned sequentially to fields in the instruction.

      From the CS33 Stanford University Report: A Programming Language for the 36O Computers, Niklaus Wirth, Introduction

      This paper is a preliminary definition of a programming language which is specifically designed for use on IBM 360 computers, and is therefore appropriately called PL36O.
      The intention is to present a programming tool which (a) closely reflects the particular structure of the 36O computer, and (b) is a superior notation to present Assembly Codes with respect to presentation and documentation of algorithms. As a consequence of (a), it enables a programmer to design programs mentioning explicitly features of this machine in a degree impossible in “higher level” languages.
      It is also felt that a highly structured language is most appropriate (a) to promote the intelligibility of texts for the human user and (b) to encourage this user to properly structure his algorithms not on paper only, but in his mind as well. The language is therefore a phrase structure language containing many constructions which quite obviously correspond to a single 36O machine instruction (cf, [l]).
      Moreover, it is hoped that through certain conventions (not mentioned in this preliminary paper) concerning the use of general registers as base address registers, programs written in PL36O can be efficiently run under a time-sharing monitor without requiring the presence of additional sophisticated relocation hardware (Model 67)°

      Presently, a compiler for PL36O is available on the B55OO computer
      This compiler is mainly intended to serve as a temporary tool for a bootstrapping process: The compiler is being rewritten in its own language and then becomes automatically available on the 36O computer. Indeed, the primary purpose of this project is to obtain a convenient tool for the development of other compilers (in particular ALGOL X) and monitor systems, where a considerable degree of machine-orientation and -dependence is desirable, but where an adequate standard of program documentation is of no less importance.

      Documents for download:

      A Programming Language for the 360 Computers, Niklaus Wirth, Stanford University CS33, 1965
      STAN-CS-71-215 PL360 Revised A Programming Language For The IBM 360 May71
      A Programming Language for the 360 Computers, M, Malcolm, revised May 1972
      PL360 Reference Manual PDF, text version
      PL360 textbook (HTML)