Oppolzer - Informatik / Stanford Pascal Compiler


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

The Stanford Pascal Compiler / Evolution Steps

Back to Compiler main page

Porting the Stanford compiler from MUSIC/SP to VM on Hercules

In 2011 I discovered a running version of Stanford Pascal on MUSIC/SP. This is an improved 1982 version (by McGill university) of 1979 Stanford Pascal which is part of some Hercules distributions. At that time, I already had a working version of VM/370 R6 running on Hercules on my Windows PC.

On Hercules VM, there was the 1979 Stanford version. My goal was to replace this by the 1982 McGill version. Because the compiler is able to compile itself, this first seemed no big problem. But soon I realized that the 1982 language is extended compared with the 1979 language, and the compiler uses these extensions excessively. So the 1982 compiler could not be compiled by the 1979 compiler.

For example, one of the extensions: structured constants:


program TEST1 ( OUTPUT ) ; type MNEM_TABLE = array [ 0 .. 255 ] of array [ 1 .. 4 ] of CHAR ; var CH : CHAR ; ... const Y : array (. 1 .. 5 .) of INTEGER = ( 4 , 5 , 7 , 9 , 12 ) ; XTBLN : MNEM_TABLE = ( '(00)' , '(01)' , '(02)' , '(03)' , 'SPM ' , 'BALR' , 'BCTR' , 'BCR ' , 'SSK ' , 'ISK ' , 'SVC ' , '(0B)' , '(0C)' , '(0D)' , 'MVCL' , 'CLCL' , 'LPR ' , 'LNR ' , 'LTR ' , 'LCR ' , 'NR ' , 'CLR ' , 'OR ' , 'XR ' , 'LR ' , ... 'AP ' , 'SP ' , 'MP ' , 'DP ' , '(FE)' , '(FF)' ) ;

The structured constants are headed by a const keyword, much the same way as simple constants, but in contrast to the simple constants, they appear after the type and var declarations. This is necessary, because the types have to be defined already, because the structured constants reference them.

The 1979 Stanford compiler didn't understand those structured constants. So I had to do a real bootstrap of the 1982 compiler to Hercules, that is: find a way to move the TEXT files (object files) to Hercules, and then maybe run them to compile the compiler on Hercules (which is kind of optional). I did this by encoding/decoding the binary object files into a real "text" format (hex encoding) and transferred them as textfiles.

The compiler then worked on Hercules, and the first correction I made was to fix some year-2000 problems: the date output on the compiler listing showed 1911, which I fixed by doing some date heuristics in PASMONN ASSEMBLE (the Pascal monitor and runtime).

Back to Compiler main page