Oppolzer - Informatik / Stanford Pascal Compiler


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

The Stanford Pascal Compiler

Last changes: 2023-04-29

New: Short Language Reference of New Stanford Pascal

Breaking News

Update 01.2023:

the Stanford Pascal Compiler release 2023.01 is now available for Windows, OS/2, Linux etc.
and for VM/CMS and MVS (or z/OS) on IBM mainframes or Hercules

see this Moshix video about the MVS distribution: 50 Year Old Stanford Pascal for MVS Updated to 2023 - M229

New features:

- CONST parameters now work with RECORDs and ARRAYs, too
- Types on parameter lists can be specified more flexibly (complete TYPE syntax, not only identifiers)
- Pointer types on function results can be specified using the arrow symbol
- LEFT and RIGHT string functions now work correctly when the second parameter is zero (null string is returned)
- a strange and difficult error in PASCAL2 (IBM 370 code generator) related to literal handling has been fixed
- PASCAL2 is now compiled with the D+ (debug) option, which involves many run-time checks and makes the PASCAL2 execution much more secure

Actual releases:

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

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

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

note: I removed the file nc.exe from the MVS distribution, because some virus scanners complained;
the CMD files, which use this tool, are still there, so a replacement for nc.exe is needed.
Or: you must install nc.exe on your machine yourself at your own risk


This picture shows an old version of the compiler (2020.11) compiling itself to 370 machine code on VM/CMS:


The Story

I am currently the maintainer of this improved and enhanced version of the Stanford Pascal compiler.

The current New Stanford Pascal compiler supports - for example - static variables, external procedures written in Pascal, Fortran or ASSEMBLER, initializations with definitions, const parameters, new builtin data types like strings of fixed and varying length, many new standard procedures and functions, a new heap management (inspired by IBM's Language Environment) and much more ...

This compiler (and the original 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)
SNAPSHOT Routine
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
Extending PASSNAP aka SNAPSHOT
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


Resources

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 2023.01)

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

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

Pascal Compiler for MVS (version of 2023.01)

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 2023.01)

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

The most recent version is available at GitHub:

https://github.com/StanfordPascal/Pascal

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.


Documentation

New Stanford Pascal - Special Topics

Short Language Reference of New Stanford Pascal
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

Pascal:

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 (Stanford 1974)
The Stanford Pascal compiler (Stanford 1979)
A Pascal P-Code Cross Compiler for the LSI 11 (Stanford 1979)
A Pascal P-Code Interpreter for the Stanford Emmy (Stanford 1979)
The Implementation of Case Statements in Pascal (University of Tasmania 1981)
Pascal/VS Language Reference Manual (IBM 1981)
The Pascal ISO 7185 Standard (1991)
Wirth: A Pioneer of Computer Science (Johannes Kepler University - Linz / Austria)

Algol:

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)

Dijkstra:

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

Other:

The PL360 Programming Language (1968)
Class Notes for a PL/I Course (1975, Argonne National Lab)
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