Oppolzer - Informatik / Stanford Pascal Compiler

Home       Lebenslauf       Schwerpunkte       Kenntnisse       Seminare       Kunden       Projekte       Produkte       Blog       Stanford Pascal       Kontakt

The Stanford Pascal Compiler

Last changes: 2022-05-25

Breaking News

Update 05.2022: the VM/CMS compiler release 2022.04 is now available; see below. It contains support for READSTR and WRITESTR (like in Pascal/VS) for the first time. Enjoy !

Update 05.2022: the compiler release 2022.04 is now available for the Windows, OS/2 and Linux environments, too. You can download it from GitHub, as usual. See below ...

The MVS or z/OS variant of the compiler (Hercules or "real" IBM mainframe) is still at 2020.12; this will be corrected in the near future.

Many thanks to Jay Moseley for checking out the MVS version of the compiler and providing instructions
and download files in TAR format on his Hercules related web site:
New Stanford PASCAL Compiler - Hercules Compilers (Jay Moseley)

Actual releases:

Compiler release 2022.04 available for Windows, OS/2 and Unix-like systems at GitHub - https://github.com/StanfordPascal/Pascal

Compiler release 2022.04 available for VM/CMS - Download
For more information see below (Resource paragraph)

Compiler release 2020.12 available for MVS (TK4-) - Download
For more information see below (Resource paragraph)

The compiler (2020.11 version) compiling itself to 370 machine code on VM/CMS:

The Story

I am currently the maintainer of an improved version of the Stanford Pascal compiler.
The Stanford Pascal compiler is an offspring of the original Pascal P4 compiler, which was written in the 1970s at ETH Zürich by a team around Niklaus Wirth.

cited from english Wikipedia:

To propagate the language rapidly, a compiler "porting kit" was created in Zürich that included a compiler that generated code for a "virtual" stack machine,
i.e., code that lends itself to reasonably efficient interpretation, along with an interpreter for that code - the Pascal-P system.
The P-system compilers were termed Pascal-P1, Pascal-P2, Pascal-P3, and Pascal-P4.
Pascal-P1 was the first version, and Pascal-P4 was the last to come from Zürich.

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.

end of citation

As I learned recently from Mark Waterbury, this is not correct. The AAEC compiler is an independent development and is not based on the P4 compiler. Mark gave me the sources, and I compared them to the original Stanford compiler, which is a P4 variant, and there are many differences. It is very unlikely if not impossible that the AAEC compiler builders had access to the P4 source.

The true story is: starting from the P4 compiler from Zürich, some work has been done in Bombay (India), and then the Stanford compiler was based on that work. The P4 compiler produces P-Code, which is independent of the target machine; to be able to run on the IBM mainframe, the P-Code needs to be translated to 370 machine code. I don't know exactly when the P-Code-to-370 translator was written; the first comment is by S. Hazeghi of Stanford. So maybe the customization of the P4 compiler to the IBM mainframe was done at Stanford; this must have been in the second half of the 1970s. The P4 compiler targetted to the IBM mainframe was then called the Stanford Pascal Compiler and was used heavily during the late 1970s and early 1980s.

Mark also told me that the Stanford compiler probably was used to bootstrap the Pascal/VS compiler from IBM, which is a self-compiling compiler (like Stanford). Pascal/VS internally uses some sort of extended P-Code, which is an extension of the P4 P-Code. BTW: the UCSD Pascal system used an intermediate code called U-Code, which is based on P4's P-Code, too.

Some years later (1982 ca.), the Stanford compiler was transferred to the McGill university in Montreal, Canada and used on their MUSIC/SP mainframe operating system. That's where I found it in 2011. The McGill version of the compiler (still called Stanford Pascal) had several significant extensions, compared to the original Stanford version of 1979.

This page tells the story what happened from 2011 to today (not much in the years 2011 to 2016),
what I did in the years since 2016, what I am doing now and what I will do in the future.

The Stanford compiler was originally targetted to IBM mainframes only.
Today it runs on VM/370 Rel.6 and on MVS 3.8j on the Hercules emulator.
And it runs on today's z/OS, too (tested first by Rene Jansen in 05.2017, thanks!).
It will sure run on modern zVM, too (at the moment limited to AMODE 24, RMODE 24).
The VM and MVS versions can be downloaded from this site (including source codes), see "Resources" below.

It also runs (tested) on Windows, OS/2, Linux (x86) and Mac OS, because I ported it there in the end of 2016.
On these platforms the P-Code generated by the first compiler pass is interpreted by a P-Code interpreter written in ANSI-C,
so it will probably run on every platform that has a C compiler. Please contact me, if you want to test it on other platforms.
The Windows (and OS/2) version is available from this site, too; see "Resources" below.

You can follow the development process more closely on this Facebook page:
Stanford Pascal on Facebook

This picture shows the Pascal compiler compiling itself on Windows
(only pass 1 needed, Pascal to P-Code; the P-Code is interpreted by the P-Code interpreter PCINT).

Evolution steps so far (will be continued ...)

Topics with this icon are not yet completed ... maybe implemented, but documentation is missing.

Starting in 2011 ...

My own Pascal history (please forgive me, this is in German)
Porting the Stanford compiler from MUSIC/SP to VM on Hercules
First extensions to the compiler in 2011
New keywords BREAK, CONTINUE, RETURN - still in 2011

Continuing work in summer 2016 ...

Extensions to the runtime system (PASMONN) in 2016
Making RESET and REWRITE optional and eliminating the implicit RESET on INPUT
Allow shorter string constants on const initializers and assignments
20 significant characters on variable names (not only 12)
Shorter string constants - continued
Dynamic Storage Management
Pointer arithmetic - new functions ADDR, PTRADD, PTRDIFF, SIZEOF, PTR2INT
Pascal library
Storage management - new functions ALLOC, FREE, ALLOCX, FREEX
Static definitions
New functions MEMSET and MEMCPY
Direct WRITE of scalar variables or expressions
Maximum length of string constants is now 254 (was 64)
Making CSP numbers consistent between PASCAL1, PASCAL2 and PASMONN
Call CMS commands from PASCAL programs
PASSNAP prints variables from more than one source file
PASSNAP prints heap variables allocated by NEW and ALLOC
Porting Stanford Pascal to Windows, OS/2 and Linux - first steps
Porting Stanford Pascal to Windows, OS/2 and Linux - other issues
Improving PASSNAP for the NODEBUG case
Porting Stanford Pascal to Windows, OS/2 and Linux - portable branch tables
Porting Stanford Pascal to Windows, OS/2 and Linux - success !!

Work of 2017 ...

Bit operations
Support undeclared procedures
Some Pascal/VS features added (DATETIME, HALT, CLOSE, TERMIN/TERMOUT)
Differences on floating point computations and rounding
Differences on floating point output
MVS version
Job control examples for the MVS compiler
Changes for the MVS compiler
Changes to PASSNAP and PASSNAPC - better error handling in PASMONN
New standard type ANYFILE - VOIDPTR renamed to ANYPTR
MVS version available for download
Stanford Pascal works on MacOS and on (modern) z/OS
Terminal flag in the Pascal FCB - effects on I/O functions
Integer and character constants in hex and binary representation
Improvement on Pascal sets - Part one
String constants built from several mixed parts (hex or binary)
SIZEOF usable on string constants
New source program scanner (PASSCAN) - separate module
C++ style comments
Binary integer constants
Write integer with leading zeroes, if desired (controlled by negative width)
Compiler messages shown at terminal (aka SYSPRINT) during compile
Old errors removed from the compiler

Compiler version 2017.12

Shorter strings (variables) can be assigned to longer strings
Compiler error messages with additional information
Verifying new P-Code instructions with the PCINT debugging features
New P-Code instructions to support inline MEMCPY and MEMSET
Calling external procedures and functions written in ASSEMBLER
New installation procedure for MVS (or z/OS)

Compiler version 2018.01

New types: CHAR (n), DECIMAL (n,m) and STRING (n) - aka VARCHAR (n)
Cheating on DECIMALs
Implementing Strings in Pascal (inspired by Pascal/VS)

The whole story on one large page

All on one page


I will no longer post the sources here explicitly, because they are on GitHub anyway (see link below), and keeping them current here is a lot of work which can be saved.

Furthermore, I would like to add that the versions on GitHub are always the best and newest and the mainframe versions for VM/CMS and MVS can be one or two released behind. I hope you don't mind.

Since 2016 ca., when I first ported the compiler to Windows, the new versions and the enhancements are first implemented and tested on Windows and then (later) on the mainframe.

Pascal Compiler for CMS (version of 2022.04)

Two AWSTape Files to TAPE LOAD the Pascal system to CMS (2022.04 version)

PAS2022A_COMP.AWS - this tape contains the needed files to run the compiler
PAS2022A.AWS - this is a TAPE DUMP of the complete development disk, including test programs etc.

Pascal Compiler for MVS (version of 2020.12)

ZIP File containing the Pascal system for MVS - or z/OS

Usage Notes for the MVS version:

the ZIP file contains an "Installation Guide" PDF, where you can find detailed instructions. You can also find it here.

Pascal Compiler for Windows and OS/2 (version of 2021.03)

The non-Mainframe versions of New Stanford Pascal are based on the P-Code interpreter PCINT.

The most recent version is available at GitHub:


Installation steps for the Windows and OS/2 version:

a) Download the Compiler ZIP File from GitHub and unpack it into a directory of your choice
b) if you're on Windows, you can use the PCINT.EXE which is in the bin subdirectory. Otherwise (if you are using OS/2 or MacOS or Unix), you will have to compile PCINT using the sources which are in the bin subdir, too.
c) Now you should choose a directory, where the executables of the compiler should be stored; this directory should be part of your PATH (for example: C:\bin ... or another directory of your choice).
d) Please copy the file COPYBIN.CMD from the script subdir to the install directory (one level up)
e) edit the SET command in COPYBIN.CMD (at the beginning) which sets the environment variable PASDIR to the directory for the executables of your choice (see step c))
f) and now start COPYBIN.CMD, so that the needed files are placed into the PASDIR directory

Now the compiler commands should work from everywhere.
Just make sure that the environment variable PASDIR always contains the directory where the compiler is (as chosen in step c)),
because it is referenced in the compiler script files.

Use PASCAL <program> or PP <program> to call the Pascal compiler; the program should be stored in a file <program>.PAS
Use PRUN <program> to run the program
set DD_<logical_filename>=<physical_filename_including_path> to assign files

For other (Non-Windows) systems:

PCINT can IMHO be compiled with every standard C compiler;
I used IBM's C compiler on OS/2 and the Open Watcom C compiler on Windows (and gcc on Linux, BTW).

The CMD files for Windows (and the installation method described above) will work for OS/2, too.
If you are on another system, you will have to adjust the script files; maybe you find some ideas in the subdirectory script_ix.
Otherwise, you can contact me directly.


New Stanford Pascal - Special Topics

External Procedures in Stanford Pascal - written in Pascal, FORTRAN or Assembler
New Stanford Pascal Installation Guide for MVS
Reading Textfiles with New Stanford Pascal
Strings in New Stanford Pascal
Troubles with Procedure Parameters

P-Code Documentation

P-Code Description (2019) - work in progress
P-Code Description (2017)
P-Code Description (2016)
P-Code Description (1978)

Old documents on different topics


The Programming Language Pascal (Niklaus Wirth, 1972)
Pascal P-Compiler Implementation Notes (ETH Zürich 3054-01)
On Code Generation in a Pascal Compiler (ETH Zürich 3056-01)
Stanford Pascal/360 Implementation Guide (1974)
The Stanford Pascal compiler (1979)
A Pascal P-Code Interpreter for the Stanford Emmy (1979)
The Implementation of Case Statements in Pascal (1981)
Pascal/VS Language Reference Manual (1981)
The Pascal ISO 7185 Standard (1991)
Wirth: A Pioneer of Computer Science


Description of Algol 60 (Rutishauser 1967)
Algol W Language Description (1972)
A Politico Social History of Algol (Bemer)
The Algol 68 Story (1978)
The Dijkstra-Zonneveld Algol 60 Compiler for the X1 (2003)
The History of the Algol Effort (2006)
Algol Anniversary (Huub de Beer 2010)
Algol in France (Mounier, Kuhn 2011)
MARST - An Algol-to-C translator (Download)


The Advent of the Recursive Procedure (2010)
E. W. Dijkstra: First Years in the Computing Science 1951 - 1968 (Van Den Hove 2009)
The Edsger W. Dijkstra Archive


The PL360 Programming Language (1968)
LE Stack and Heap Implementation (IBM 2005)
Columbia University Computing History
40 Jahre Informatik in München (2007)
Evaluation of Algol 68, Pascal, ... for a Common High Order Programming Language (1976)
DOD Language Evaluation (1977)
A Methodology for Evaluating Languages and their Compilers for Secure Applications (1978)

Back to main page