Oppolzer - Informatik / Stanford Pascal Compiler


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

The Stanford Pascal Compiler

Last changes: 2018-05-11

Breaking News

New compiler release 2018.05 available for VM/CMS, MVS (TK4-), Windows and OS/2.

The MVS (TK4-) installation procedure has been reworked (again)

Top feature of the new release:

- the Pascal/VS string datatype and its functions are now available in the mainframe version of New Stanford Pascal, too;
all new string related P-Codes (beginning with the letter V, which stands for VarChar) have been successfully implemented,
that is: they are translated to inline 370 machine code most of the time.

Caution: because this implementation was a hard piece of work, there may still be some errors in the string handling on the mainframe.
And: some runtime checks are not yet implemented, for example checks for the defined maximum length, so that overwriting of other storage areas
is still possible. This will be repaired in the mid term future.

If you don't use strings (or use them carefully), this version should be a very stable version.

The compiler 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 Zurich by a team around Niklaus Wirth.

cited from english Wikipedia:

To propagate the language rapidly, a compiler "porting kit" was created in Zurich 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 Zurich.

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

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).
That's where I found it in 2011.

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 compiler was originally targetted (since the AAEC days) 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 (Compiler Versions 2018.05 and 2018.02)

Warning: no warranty at all for the software contained here; I don't recommend that you use it for any production work. The AWS Tape file may contain an older version, which is not as current as the development stories from above. The source codes will be more current, but maybe you will not be able to compile them using the older versions on the AWS Tape, because it is sometimes necessary to apply incompatible extensions to the compiler. If I have time, I will put the new version to the AWS Tape, too (if the new version is stable enough).

If you have difficulties running or compiling the actual versions, contact me directly. I will help you as soon as I can, and I would like it if you test this compiler using some Pascal sources you maybe have.

The source code of the first pass: PASCAL1.PAS
The source code of the second pass: PASCAL2.PAS
The symbol scanner module: PASSCAN.PAS
Backup version 2018.02 first pass: PASCAL1A.PAS
Backup version 2018.02 second pass: PASCAL2A.PAS
To start Pascal programs using VM/CMS: XRUNPARM.ASS
The Pascal monitor and runtime: PASMONN.ASS
The source code of the LIBX library routines: PASLIBX.PAS
The source code of the UTILS library routines: PASUTILS.PAS

The source code of the MVS snapshot routine: PASSNAP.PAS
The source code of the CMS snapshot routine: PASSNAPC.PAS

The source code of the PASFORM source formatter utility: PASFORM.PAS
The source code of the XCOMP compare utility: XCOMP.PAS

Pascal Compiler for CMS (version of 2018.05)

AWSTape File to TAPE LOAD the Pascal system to CMS
AWSTape File (2018.02 version)

Pascal Compiler for MVS (version of 2018.05)

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

The most recent version is available at GitHub:

https://github.com/StanfordPascal/Pascal

Usage Notes for the Windows and OS/2 version:

Unzip the ZIP file from GitHub to a directory of your choice (or simply pull it).

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

I removed the precompiled executables PCINT.EXE (for Windows) and PCINT2.EXE (for OS/2) from this site.
PCINT.EXE can easily be retrieved from the GitHub repository, too.
PCINT2.EXE for OS/2 is not contained in the GitHub repository any more.
The OS/2 variant of PCINT can be built from the Windows source in the GitHub repository,
using any C compiler. Look at aw.cmd to see, how to do it. If you need a OS/2 EXE
of the current PCINT, please contact me offline.

Recompiling PCINT is another option; use any C compiler you like.
I used IBM's C compiler on OS/2 and the Open Watcom C compiler on Windows (gcc on Linux, BTW).

Use 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

Pascal Compiler for Linux, MacOS and other systems

please contact me directly
(or: try to build a version of PCINT on the system you are interested in ...
take the sources from the GitHub repository above.
Please keep me informed, if you have successfully ported PCINT to another platform).

Documentation

The Programming Language Pascal (Niklaus Wirth, 1972)
Stanford Pascal/360 Implementation Guide (1974)
P-Code Description (1978)
The Stanford Pascal compiler (1979)
The Implementation of Case Statements in Pascal (1981)
Pascal/VS Language Reference Manual (1981)
The Pascal ISO 7185 Standard (1991)
LE Stack and Heap Implementation (IBM 2005)
P-Code Description (2016)
External Procedures in Stanford Pascal - written in Pascal, FORTRAN or Assembler (2017)
P-Code Description (2017) - work in progress
Strings in New Stanford Pascal
New Stanford Pascal Installation Guide for MVS

Back to main page