DEC PDP-10 Pascal compiler

1972 }
}
} Bootstrap attempt with CDC-6400 PASCAL compiler
} (simulating a CDC-6400 on a PDP-10:
} 90 minutes for compilation)
}
}
}
1973 }
} Bootstrap of PASCAL-compiler for
} hypothetical stack machine by simulating
} this stack machine on the PDP-10: 10 minutes
}
}
1974 }
Upgrading the compiler into a competitive
} tool for small program development
}
} Development of a version which generates
} relocatable object code compatible with
} LINK-10 and an interactive source level debugging
} option
}
}
1975 }
} Fully implement STANDARD PASCAL
}
}
}
1976 }
} Adapt to DECSystem-10 Concise Command Language
} Add large range of options (including most of
} the PASCAL-6000. ones) to provice a
} comfortable programming environment for
} large systems.

Px compilers

The Pascal-P compiler was created in 1973, then went through several versions, which so far have not been available. Ch. Jacobi gives an overview of the Pascal-P versions in PUG newsletter #4:

Name Origination Year Source Description
Pascal P1 Zurich 1973 No Either of the early Pascal-P systems (released in March and July 1973 respectively)
Pascal-P2 Zurich 1974 Yes The Pascal-P system released in May 74
Pascal-P3 Zurich 1976 No The new Pascal-P system with the same hypothetical machine as the one underlying the Pascal P2 system
Pascal-P4 Zurich 1976 Yes The new Pascal-P system with a slightly modified hypothetical machine (allowing a more efficient implementation)

The versions of P1 that existed have (so far) not been available. The revised version, P2, is available, and was used as the basis for the UCSD system. P3 was a “step” implementation used to bridge between P2 and P4, and is also not obtainable.

The last major version of Pascal-P was P4.

PL/0

PL/0 is a small educational language dsigned and implemented by Wirth to be used as an example of compiler development.

The language was presented by Niklaus Wirth in his book “Algorithms + Data Structures = Programs” (1975). LAter versions of this book did not contain PL/0.
His later book “Compilerbau” (“Compiler Construction”, 1976) provided a full source code of PL/0 compiler written in Pascal. Later editions (3rd, 1984)  the PL/0 compiler was rewritten to Modula.
After Oberon was conceived the example language was succeeded by Oberon-0.

The capabilities of the language were intentionally limited:

–the only data type are integer numbers. Still all constants and variables used have to be declared explicitly, not deduced at compile-time.
–the only operators provided are arithmetical and comparison ones.
–there is one built-in function odd which checks whether the integer argument is odd.
– there are no input/output routines; instead the compiler prints the new value of each variable whenever it gets changed.
– the flow control structures are represented by if-then and while-do constructs, as well as user-defined procedures (which can’t accept any parameters).

The syntax of PL/0 described in extended Backus-Naur form

program = block "." .

block = [ "const" ident "=" number {"," ident "=" number} ";"]
        [ "var" ident {"," ident} ";"]
        { "procedure" ident ";" block ";" } statement .

statement = [ ident ":=" expression | "call" ident 
              | "?" ident | "!" expression 
              | "begin" statement {";" statement } "end" 
              | "if" condition "then" statement 
              | "while" condition "do" statement ].

condition = "odd" expression |
            expression ("="|"#"|"<"|"<="|">"|">=") expression .

expression = [ "+"|"-"] term { ("+"|"-") term}.

term = factor {("*"|"/") factor}.

factor = ident | number | "(" expression ")".

Elements of syntax

Case-sensitivity yes
Variable assignment :=
Variable declaration var
Block begin … end
Physical (shallow) equality =
Physical (shallow) inequality #
Comparison < >
Function definition procedure <name>; <body>;
Function call call <name>
Sequence ;
If – then if <condition> then <trueBlock>
Loop forever while 1 = 1 do <loopBody>
While condition do while do <loopBody>

To compile with Delphi, Freepascal, or any compiler where object is a reserved name: rename identifier ‘object’

program pl0(input,output);
{pl/0 compiler with code generation}
label 99;
const norw = 11;     {no. of reserved words}
   txmax = 100;      {length of identifier table}
   nmax = 14;        {max. no. of digits in numbers}
   al = 10;          {length of identifiers}
   amax = 2047;      {maximum address}
   levmax = 3;       {maximum depth of block nesting}
   cxmax = 200;      {size of code array}
type symbol =
   (nul,ident,number,plus,minus,times,slash,oddsym,
    eql,neq,lss,leq,gtr,geq,lparen,rparen,comma,semicolon,
    period,becomes,beginsym,endsym,ifsym,thensym,
    whilesym,dosym,callsym,constsym,varsym,procsym);
    alfa = packed array [1..al] of char;
    object = (constant,varible,proc);
    symset = set of symbol;
    fct = (lit,opr,lod,sto,cal,int,jmp,jpc);   {functions}
    instruction = packed record
                     f: fct;           {function code}
                     l: 0..levmax;     {level}
                     a: 0..amax        {displacement address}
                  end;
{   lit 0,a  :  load constant a
    opr 0,a  :  execute operation a
    lod l,a  :  load varible l,a
    sto l,a  :  store varible l,a
    cal l,a  :  call procedure a at level l
    int 0,a  :  increment t-register by a
    jmp 0,a  :  jump to a
    jpc 0,a  :  jump conditional to a   }
var ch: char;         {last character read}
    sym: symbol;      {last symbol read}
    id: alfa;         {last identifier read}
    num: integer;     {last number read}
    cc: integer;      {character count}
    ll: integer;      {line length}
    kk, err: integer;
    cx: integer;      {code allocation index}
    line: array [1..81] of char;
    a: alfa;
    code: array [0..cxmax] of instruction;
    word: array [1..norw] of alfa;
    wsym: array [1..norw] of symbol;
    ssym: array [char] of symbol;
    mnemonic: array [fct] of
                 packed array [1..5] of char;
    declbegsys, statbegsys, facbegsys: symset;
    table: array [0..txmax] of
           record name: alfa;
              case kind: object of
              constant: (val: integer);
              varible, proc: (level, adr: integer)
           end;
procedure error(n: integer);
begin writeln(' ****',' ': cc-1, '^',n: 2); err := err+1
end {error};
 
procedure getsym;
   var i,j,k: integer;
 
   procedure getch;
   begin if cc = ll then
      begin if eof(input) then
                 begin write(' program incomplete'); goto 99
                 end;
         ll := 0; cc := 0; write(cx: 5,' ');
         while not eoln(input) do
            begin ll := ll+1; read(ch); write(ch); line[ll]:=ch
            end;
         writeln; readln; ll := ll + 1; line[ll] := ' ';
      end;
      cc := cc+1; ch := line[cc]
   end {getch};
 
begin {getsym}
   while ch  = ' ' do getch;
   if ch in ['a'..'z'] then
   begin {identifier or reserved word} k := 0;
      repeat if k < al then begin k := k+1; a[k] := ch end; getch; until not(ch in ['a'..'z','0'..'9']); if k >= kk then kk := k else
         repeat a[kk] := ' '; kk := kk-1
         until kk = k;
      id := a; i := 1; j := norw;
      repeat k := (i+j) div 2;
         if id <= word[k] then j := k-1; if id >= word[k] then i := k+1
      until i > j;
      if i-1 > j then sym := wsym[k] else sym := ident
   end else
   if ch in ['0'..'9'] then
   begin {number} k := 0; num := 0; sym := number;
      repeat num := 10*num + (ord(ch)-ord('0'));
         k := k+1; getch
      until not(ch in ['0'..'9']);
      if k > nmax then error(30)
   end else
   if ch = ':' then
   begin getch;
      if ch = '=' then
      begin sym := becomes; getch
      end else sym := nul;
   end else
   begin sym := ssym[ch]; getch
   end
end {getsym};
 
procedure gen(x: fct; y,z: integer);
begin if cx > cxmax then
           begin write(' program too long'); goto 99
           end;
   with code[cx] do
      begin f := x; l := y; a := z
      end;
   cx := cx + 1
end {gen};
 
procedure test(s1,s2: symset; n: integer);
begin if not(sym in s1) then
        begin error(n); s1 := s1 + s2;
           while not(sym in s1) do getsym
        end
end {test};
 
procedure block(lev,tx: integer; fsys: symset);
   var dx: integer;     {data allocation index}
      tx0: integer;     {initial table index}
      cx0: integer;     {initial code index}
   procedure enter(k: object);
   begin {enter object into table}
      tx := tx + 1;
      with table[tx] do
      begin name := id; kind := k;
         case k of
         constant: begin if num > amax then
                              begin error(30); num :=0 end;
                      val := num
                   end;
         varible: begin level := lev; adr := dx; dx := dx + 1;
                  end;
         proc: level := lev
         end
      end
   end {enter};
 
   function position(id: alfa): integer;
      var i: integer;
   begin {find indentifier id in table}
      table[0].name := id; i := tx;
      while table[i].name <> id do i := i-1;
      position := i
   end {position};
 
   procedure constdeclaration;
   begin if sym = ident then
      begin getsym;
         if sym in [eql, becomes] then
         begin if sym = becomes then error(1);
            getsym;
            if sym = number then
               begin enter(constant); getsym
               end
            else error(2)
         end else error(3)
      end else error(4)
   end {constdeclaration};
 
   procedure vardeclaration;
   begin if sym = ident then
           begin enter(varible); getsym
           end else error(4)
   end {vardeclaration};
 
   procedure listcode;
      var i: integer;
   begin {list code generated for this block}
      for i := cx0 to cx-1 do
         with code[i] do
            writeln(i:5, mnemonic[f]:5, 1:3, a:5)
   end {listcode};
 
   procedure statement(fsys: symset);
      var i, cx1, cx2: integer;
      procedure expression(fsys: symset);
         var addop: symbol;
         procedure term(fsys: symset);
            var mulop: symbol;
            procedure factor(fsys: symset);
               var i: integer;
            begin test(facbegsys, fsys, 24);
               while sym in facbegsys do
               begin
                  if sym = ident then
                  begin i:= position(id);
                     if i = 0 then error(11) else
                     with table[i] do
                     case kind of
                        constant: gen(lit, 0, val);
                        varible: gen(lod, lev-level, adr);
                        proc: error(21)
                     end;
                     getsym
                  end else
                  if sym = number then
                  begin if num >  amax then
                           begin error(30); num := 0
                           end;
                     gen(lit, 0, num); getsym
                  end else
                  if sym = lparen then
                  begin getsym; expression([rparen]+fsys);
                     if sym = rparen then getsym else error(22)
                  end;
                  test(fsys, [lparen], 23)
               end
            end {factor};
 
         begin {term} factor(fsys+[times, slash]);
            while sym in [times, slash] do
             begin mulop:=sym;getsym;factor(fsys+[times,slash]);
              if mulop=times then gen(opr,0,4) else gen(opr,0,5)
             end
         end {term};
      begin {expression}
         if sym in [plus, minus] then
            begin addop := sym; getsym; term(fsys+[plus,minus]);
               if addop = minus then gen(opr, 0,1)
            end else term(fsys+[plus, minus]);
         while sym in [plus, minus] do
            begin addop := sym; getsym; term(fsys+[plus,minus]);
               if addop=plus then gen(opr,0,2) else gen(opr,0,3)
            end
      end {expression};
 
      procedure condition(fsys: symset);
         var relop: symbol;
      begin
         if sym  = oddsym then
         begin getsym; expression(fsys); gen(opr, 0, 6)
         end else
         begin expression([eql, neq, lss, gtr, leq, geq]+fsys);
            if not(sym in [eql, neq, lss, leq, gtr, geq]) then
               error(20) else
            begin relop := sym; getsym; expression(fsys);
               case relop of
                  eql: gen(opr, 0, 8);
                  neq: gen(opr, 0, 9);
                  lss: gen(opr, 0, 10);
                  geq: gen(opr, 0, 11);
                  gtr: gen(opr, 0, 12);
                  leq: gen(opr, 0, 13);
               end
            end
         end
      end {condition};
 
   begin {statement}
      if sym = ident then
      begin i := position(id);
         if i = 0 then error(11) else
         if table[i].kind <> varible then
            begin {assignment to non-varible} error(12); i := 0
            end;
         getsym; if sym = becomes then getsym else error(13);
         expression(fsys);
         if i <> 0 then
            with table[i] do gen(sto, lev-level, adr)
      end else
      if sym = callsym then
      begin getsym;
         if sym <> ident then error(14) else
            begin i := position(id);
               if i = 0 then error(11) else
               with table[i] do
                  if kind=proc then gen(cal, lev-level, adr)
                  else error(15);
               getsym
            end
      end else
      if sym = ifsym then
      begin getsym; condition([thensym, dosym]+fsys);
         if sym = thensym then getsym else error(16);
         cx1 := cx; gen(jpc, 0, 0);
         statement(fsys); code[cx1].a := cx
      end else
      if sym = beginsym then
      begin getsym; statement([semicolon, endsym]+fsys);
         while sym in [semicolon]+statbegsys do
         begin
            if sym = semicolon then getsym else error(10);
            statement([semicolon, endsym]+fsys)
         end;
         if sym = endsym then getsym else error(17)
      end else
      if sym = whilesym then
      begin cx1 := cx; getsym; condition([dosym]+fsys);
         cx2 := cx; gen(jpc, 0, 0);
         if sym = dosym then getsym else error(18);
         statement(fsys); gen(jmp, 0, cx1); code[cx2].a := cx
      end;
      test(fsys, [], 19)
   end {statement};
 
begin {block} dx:=3; tx0:=tx; table[tx].adr:=cx; gen(jmp,0,0);
   if lev > levmax then error(32);
   repeat
      if sym = constsym then
      begin getsym;
         repeat constdeclaration;
            while sym = comma do
               begin getsym; constdeclaration
               end;
            if sym = semicolon then getsym else error(5)
         until sym <> ident
      end;
      if sym = varsym then
      begin getsym;
         repeat vardeclaration;
            while sym = comma do
               begin getsym; vardeclaration
               end;
            if sym = semicolon then getsym else error(5)
         until sym <> ident;
      end;
      while sym = procsym do
      begin getsym;
         if sym = ident then
            begin enter(proc); getsym
            end
         else error(4);
         if sym = semicolon then getsym else error(5);
         block(lev+1, tx, [semicolon]+fsys);
         if sym = semicolon then
            begin getsym;test(statbegsys+[ident,procsym],fsys,6)
            end
         else error(5)
      end;
      test(statbegsys+[ident], declbegsys, 7)
   until not(sym in declbegsys);
   code[table[tx0].adr].a := cx;
   with table[tx0] do
      begin adr := cx; {start adr of code}
      end;
   cx0 := 0{cx}; gen(int, 0, dx);
   statement([semicolon, endsym]+fsys);
   gen(opr, 0, 0); {return}
   test(fsys, [], 8);
   listcode;
end {block};
 
procedure interpret;
   const stacksize = 500;
   var p,b,t: integer; {program-, base-, topstack-registers}
      i: instruction; {instruction register}
      s: array [1..stacksize] of integer; {datastore}
   function base(l: integer): integer;
      var b1: integer;
   begin b1 := b; {find base l levels down}
      while l > 0 do
         begin b1 := s[b1]; l := l - 1
         end;
      base := b1
   end {base};
 
begin writeln(' start pl/0');
   t := 0; b := 1; p := 0;
   s[1] := 0; s[2] := 0; s[3] := 0;
   repeat i := code[p]; p := p + 1;
      with i do
      case f of
      lit: begin t := t + 1; s[t] := a
           end;
      opr: case a of {operator}
           0: begin {return}
                 t := b - 1; p := s[t + 3]; b := s[t + 2];
              end;
           1: s[t] := -s[t];
           2: begin t := t - 1; s[t] := s[t] + s[t + 1]
              end;
           3: begin t := t - 1; s[t] := s[t] - s[t + 1]
              end;
           4: begin t := t - 1; s[t] := s[t] * s[t + 1]
              end;
           5: begin t := t - 1; s[t] := s[t] div s[t + 1]
              end;
           6: s[t] := ord(odd(s[t]));
           8: begin t := t - 1; s[t] := ord(s[t] = s[t + 1])
              end;
           9: begin t := t - 1; s[t] := ord(s[t] <> s[t + 1])
              end;
          10: begin t := t - 1; s[t] := ord(s[t] < s[t + 1]) end; 11: begin t := t - 1; s[t] := ord(s[t] >= s[t + 1])
              end;
          12: begin t := t - 1; s[t] := ord(s[t] > s[t + 1])
              end;
          13: begin t := t - 1; s[t] := ord(s[t] <= s[t + 1])
              end;
          end;
      lod: begin t := t + 1; s[t] := s[base(l) + a]
           end;
      sto: begin s[base(l)+a] := s[t]; writeln(s[t]); t := t - 1
           end;
      cal: begin {generate new block mark}
              s[t + 1] := base(l); s[t + 2] := b; s[t + 3] := p;
              b := t + 1; p := a
           end;
      int: t := t + a;
      jmp: p := a;
      jpc: begin if s[t] = 0 then p := a; t := t - 1
           end
      end {with, case}
   until p = 0;
   write(' end pl/0');
end {interpret};

begin {main program}
   for ch := chr(0) to chr(255) do ssym[ch] := nul;
   word[ 1] := 'begin     ';      word[ 2] := 'call      ';
   word[ 3] := 'const     ';      word[ 4] := 'do        ';
   word[ 5] := 'end       ';      word[ 6] := 'if        ';
   word[ 7] := 'odd       ';      word[ 8] := 'procedure ';
   word[ 9] := 'then      ';      word[10] := 'var       ';
   word[11] := 'while     ';
   wsym[ 1] := beginsym;     wsym[ 2] := callsym;
   wsym[ 3] := constsym;     wsym[ 4] := dosym;
   wsym[ 5] := endsym;       wsym[ 6] := ifsym;
   wsym[ 7] := oddsym;       wsym[ 8] := procsym;
   wsym[ 9] := thensym;      wsym[10] := varsym;
   wsym[11] := whilesym;
   ssym[ '+'] := plus;       ssym[ '-'] := minus;
   ssym[ '*'] := times;      ssym[ '/'] := slash;
   ssym[ '('] := lparen;     ssym[ ')'] := rparen;
   ssym[ '='] := eql;        ssym[ ','] := comma;
   ssym[ '.'] := period;     ssym[ '#'] := neq;
   ssym[ '<'] := lss; ssym[ '>'] := gtr;
   ssym[ '['] := leq;        ssym[ ']'] := geq;
   ssym[ ';'] := semicolon;
   mnemonic[lit] := '  lit';   mnemonic[opr] := '  opr';
   mnemonic[lod] := '  lod';   mnemonic[sto] := '  sto';
   mnemonic[cal] := '  cal';   mnemonic[int] := '  int';
   mnemonic[jmp] := '  jmp';   mnemonic[jpc] := '  jpc';
   declbegsys := [constsym, varsym, procsym];
   statbegsys := [beginsym, callsym, ifsym, whilesym];
   facbegsys  := [ident, number, lparen];
   page(output); err := 0;
   cc := 0; cx := 0; ll := 0; ch := ' '; kk := al; getsym;
   block(0, 0, [period]+declbegsys+statbegsys);
   if sym <> period then error(9);
  if err=0 then interpret else write(' errors in pl/0 program');
99: writeln
end.

Superpascal and Solo

SuperPascal

Not much of Per Brinch Hansen’s programs/compilers/operating systems are available online, his books are the only source. Recently the sources of SuperPascal appeared online at his website (http://brinch-hansen.net/). This subset of Pascal, enhanced with constructs for parallel computing is not super Pascal, but a well structured, easy to understand compiler-interpreter combination for the study of concurrent programming.
Since the information is available in shar archive form, with Latex encoded documents. I took the liberty to convert the files to more convenient text and pdf format:

Sources of the compiler/interpreter. For Sun Pascal workstation, in nearly standard Pascal.

 Note on the Sun Pascal clock statement used in the interpreter

 Read this

The SuperPascal User Manual

The Programming Language SuperPascal

The SuperPascal software notes

 Original shar archive

See also the page on Superpascal

Solo Operating system, Concurrent Pascal, Sequential pascal

On bitsavers.org the Solo operating system disk is archived. Some kind person extracted the sources on the disk and made available the operating systeme Solo, Sequential Pascal and Concurrent Pascal compiler and the runtime sources for the PDP-11. Compared to SuperPascal, these are production quality products, well worth a study.

The Solo Operating description

The archive with the sources of Solo and the Pascal compilers

Pascal compiler sources

Steven Pemberton’s site with code and thorough documentation of the P4 compiler, the text of the book:
Pascal Implementation: The P4 Compiler and Interpreter, by Steven Pemberton and Martin Daniels, Ellis Horwood, ISBN: 0-13-653-0311

On Scott Moore’s Standard Pascal site an interesting page on the PL/0, pascal-s and P4 compilers with sources and fixes. Pascal-s compiler, the small and easy to understand subset of Pascal by Wirth.

The Amsterdam Compiler kit, of which I witnessed the first versions around 1980 now as opensource for Linux etc. Targets include all major cpu’s form the past (6502, 8080, Z80) until modern Intel 86 architecture. Full source of compiler and interpreters and documentation included.

Pascal-M

Pascal-M, written by Mark Rustad, a version of the P2 compiler (without floating point) and a p-code (M-code) interpreter suitable and optimized for microprocessors.
With permission from Mark to publish it.

See for the recreated and scanned verson 1.x of this compiler/interpreter combination, actually working on the KIM-1 with 32K extra memory.

Pascal on the Commodore

A Pascal compiler-interpreter combination, including sources, well integrated on the Commodore 64 and C128 computers, by Prof Dr Florian Matthes

Superpascal compiler

There is now a FPC version of SuperPascal at https://github.com/octonion/superpascal, archived here.

From Wikipedia:

SuperPascal is based on Niklaus Wirth’s sequential language Pascal, extending it with features for safe and efficient concurrency. Pascal itself was used heavily as a publication language in the 1970s; it was used to teach structured programming practices and featured in text books, for example, on compilers and programming languages. Brinch Hansen had earlier developed the language Concurrent Pascal, one of the earliest concurrent languages for the design of operating systems and real-time control systems.

The requirements of SuperPascal were based on the experience gained by Brinch Hansen over three years in developing a set of model parallel programs, which implemented methods for common problems in computational science.This experimentation allowed him to make the following conclusions about the future of parallel scientific computing:

Future parallel computers will be general-purpose, allowing programmers to think in terms of problem-orientated process configurations. This was based on his experience programming networks of transputers, which were general-purpose processors able to be connected in arrays, trees or hypercubes.
Regular problems in computational science require only deterministic parallelism, that is, expecting communication from a particular channel, rather than from several.
Parallel scientific algorithms can be developed in an elegant publication language and tested on a sequential computer. When it is established an algorithm works, it can easily be implemented in a parallel implementation language.

These then led to the following requirements for a parallel publication language:

-The language should extend a widely used standard language with deterministic parallelism and message communication. The extensions should be in the spirit of the standard language.
-The language should make it possible to program arbitrary configurations of parallel processes connected by communication channels. These configurations may be defined iteratively or recursively and created dynamically.
-The language should enable a single-pass compiler to check that parallel processes do not interfere in a time-dependent manner.

Features
The key ideas in the design of SuperPascal was to provide a secure programming, with abstract concepts for parallelism.

Security
SuperPascal is secure in that it should enable its compiler and run-time system to detect as many cases as possible in which the language concepts break down and produce meaningless results. SuperPascal imposes restrictions on the use of variables that enable a single-pass compiler to check that parallel processes are disjoint, even if the processes use procedures with global variables, eliminating time-dependent errors. Several features in Pascal were ambiguous or insecure and were omitted from SuperPascal, such as labels and goto statements, pointers and forward declarations.

Parallelism
The parallel features of SuperPascal are a subset of occam 2, with the added generality of dynamic process arrays and recursive parallel processes.

A parallel statement denotes that the fixed number of statements it contains must be executed in parallel. For example:

parallel
  source() |
  sink()
end

A forall statement denotes the parallel execution of a statement by a dynamic number of processes, for example:

forall i := 0 to 10 do
  something()

Channels and communication
Parallel processes communicate by sending typed messages through channels created dynamically. Channels are not variables in themselves, but are identified by a unique value known as the channel reference, which are held by channel variables. A channel is declared, for example, by the declaration

type channel = *(boolean, integer);
  var c: channel;

which defines a new (mixed) type named channel and a variable of this type named c. A mixed type channel is restricted to transmitting only the specified types, in this case boolean and integer values. The channel c is initialised by the open statement:

open(c)

Message communication is then achieved with the send(channel, value) and receive(channel, variable) statements. The expression or variable providing the value for send, and the variable in receive, must both be of the same type as the first channel argument. The following example shows the use of these functions in a process that receives a value from the left channel and outputs it on the right one.

var left, right: channel; a: number;
  receive(left, a);
  send(right, a)

The functions send and receive can both take multiple input and output arguments respectively:

  send(channel, e1, e2,..., en);
  receive(channel, v1, v2,..., vn)

The following run-time communication errors can occur:
– Channel contention occurs when two parallel processes both attempt to send or receive on the same channel simultaneously.
A message type error occurs when two parallel processes attempt to communicate through the same channel and the output expression and input variable are of different types.
Deadlock occurs when a send or receive operation waits indefinitely for completion.

– Recursive procedures can be combined with parallel and forall statements to create parallel recursive processes. The following example shows how a pipeline of processes can be recursively defined using a parallel statement.

procedure pipeline(min, max: integer; left, right: channel);
var middle: channel;
begin
  if min < max then
    begin
      open(middle);
      parallel
        node(min, left, middle) |
        pipeline(min + 1, max, middle, right)
      end
    end
  else node(min, left, right)
end;
end;

Another example is the recursive definition of a process tree:

procedure tree(depth: integer, bottom: channel);
var left, right: channel;
begin
  if depth > 0 then
    begin
      open(left, right);
      parallel
        tree(depth - 1, left) |
        tree(depth - 1, right) |
        root(bottom, left, right)
      end
    end
  else leaf(bottom)

Interference control
The most difficult aspect of concurrent programming is unpredictable or non-reproducible behaviour caused by time-dependent errors. Time-dependent errors are caused by interference between parallel processes, due to variable updates or channel conflicts. If processes sharing a variable, update it at unpredictable times, the resulting behaviour of the program is time-dependent. Similarly, if two processes simultaneously try to send or receive on a shared channel, the resulting effect is time-dependent.

SuperPascal enforces certain restrictions on the use of variables and communication to minimise or eliminate time-dependent errors. With variables, a simple rule is required: parallel processes can only update disjoint sets of variables. For example, in a parallel statement a target variable cannot be updated by more than a single process, but an expression variable (which can’t be updated) may be used by multiple processes. In some circumstances, when a variable such as an array is the target of multiple parallel processes, and the programmer knows its element-wise usage is disjoint, then the disjointness restriction may be overridden with a preceding statement.

Structure and syntax
SuperPascal is a block structured language, with the same basic syntax as Pascal. A program consists of a header, global variable definitions, function or procedure definitions and a main procedure. Functions and procedures consists of blocks, where a block is a set of statements. Statements are separated by semicolons, as opposed to languages like C or Java, where they are terminated by semicolons.

The following is an example of a complete SuperPascal program, which constructs a pipeline communication structure with 100 nodes. A master node sends an integer token to the first node, this is then passed along the pipeline and incremented at each step, and finally received by the master node and printed out.

program pipeline;

const
    len = 100;

type
    channel = *(integer);

var
    left, right: channel;
    value: integer;

procedure node(i: integer; left, right: channel);
var value: integer;
begin
    receive(left, value);
    send(right, value+1)
end;

procedure create(left, right: channel);
type row = array [0..len] of channel;
var c: row; i: integer;
begin
    c[0] := left;
    c[len] := right;
    for i := 1 to len-1 do
        open(c[i]);
    forall i := 1 to len do
        node(i, c[i-1], c[i])
end;

begin
    open(left, right);

    parallel
        send(left, 0) |
        create(left, right) |
        receive(right, value)
    end;

    writeln('The resulting value is ', value)
end.

Implementation
The SuperPascal software can be accessed freely from the Brinch Hansen Archive. It consists of a compiler and interpreter, which are both written in normal, sequential Pascal (ISO Level 1 standard Pascal). This is supported by the GNU Pascal compiler and newer versions of the Free Pascal compiler (2.7.1+) with the -Miso switch, with the following respective small modifications to the code.

For GPC, the file interpret.p uses the non-standard clock function (line 1786), which is used to obtain the system time. Instead, the Extended Pascal getTimeStamp function can be used (which is supported by the GNU Pascal compiler), by declaring a variable of type TimeStamp, setting that with the current time using getTimeStamp and assigning the Second field of the TimeStamp to the variable t.

Free Pascal also needs a solution to the above “clock” problem (On windows, just declare gettickcount as external with “clock” as name). In addition, the reset/rewrites that are marked as non-standard in the source need to be changed to assign/reset (or rewrite) pairs. (GPC probably only errors on this if you enable strict flags), and the C preprocessor commands #include ‘xx’ must be changed to {$include ‘xx’}.

There is now a FPC version of SuperPascal at https://github.com/octonion/superpascal, archived here.

 

post

Project Oberon

Hardware FPGA implementation document by Niklaus Wirth

Project Oberon emulators

Emulator for the Oberon RISC machine by Peter de Wachter

Oberon RISC Emulator for Pascal Markus Greim

Project Oberon emulator in JavaScript and Java  Michael Schierl

Project Oberon as MacIntosh  application Oberon Workstation

Pipistrella hardware FPGA

OberonStation.  Hardware with FPGA to run Project Oberon.
For sale!

Here is a summary of acronyms and version names jwr robrts net gleaned from
various messages and sources. Please provide feedback and corrections
as appropriate.

ALO ARM Linux Oberon (Oberon in LNO family, for ARM CPU eg Raspberry Pi)
ETHO ETH Oberon (ETH is Eidgen?ssische Technische Hochschule Z?rich)
LEO Linux ETH Oberon [ETHO 2.4.3 for Linux x86]
LNO Linux Native Oberon
NO Native Oberon
OCP Oberon Community Platform
OLR Oberon Linux Revival

Is ETH-Linux-Oberon the same as LEO or LNO? (Probably it is LEO.) Is
Linux-ETH-Oberon the same as LEO? Same as ETH-Linux-Oberon?
See https://lists.inf.ethz.ch/pipermail/oberon/2015/007996.html
and https://lists.inf.ethz.ch/pipermail/oberon/2008/005410.html

BB BlackBox Component Builder, Component Pascal IDE
from Oberon Microsystems, http://www.oberon.ch/blackbox.html
CP Component Pascal
[A dialect in the Oberon family most similar to Oberon-2]

AOS Active Object System (2003)
UnixAOS Unix-based AOS
WinAOS Windows-based AOS
Bluebottle New system based on AOS kernel (2005)
A2 New system after Bluebottle (2008)
See http://www.oberon.ethz.ch/ for AOS/Bluebottle/A2 history
Crazy-Fresh Bluebottle [see http://www.ethoberon.ethz.ch/] Crazy-Fresh
A2 [see http://sourceforge.net/projects/a2oberon/files/]

The following appear to be versions of the language definition itself.
In another message another day I plan to identify documentation for each.

Original Oberon (1987/88/90)
Revised Oberon (1992) [later called Oberon-07]
Oberon-2 is a compatible superset of Revised Oberon (1992)
Oberon-07 is a new language based on Oberon and Oberon-SA
See http://oberon07.com/ and http://oberon07.com/FAQ.xhtml
See https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.pdf
See https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.Report.pdf
Project Oberon (1992) Ceres-based NS32032 implementation of Revised Oberon
see http://www.ethoberon.ethz.ch/WirthPubl/ProjectOberon.pdf
Project Oberon (2013) FPGA-based RISC5 implementation of Oberon-07
see http://www.projectoberon.com/ and
https://www.inf.ethz.ch/personal/wirth/
Oakwood Guidelines for Oberon-2 Compiler Developers

Other names found for various Oberon implementations and versions include:

Oberon S3 = Oberon System 3 (Became ETH Oberon)
Oberon V4 (Associated with both ETH and University of Linz)
See http://sourceforge.net/projects/oberon/ and
http://www.ssw.uni-linz.ac.at/Research/Projects/Oberon.html
See http://users.cms.caltech.edu/~cs140/140a/Oberon/system_faq.html for
Oberon = V1 ( V2 V4 | System3 )
Oberon V1 [Original Oberon??]
Oberon V2 [??]
Oberon V4 [Started at ETH, more development at University of Linz]
Oberon System3 [Became ETH Oberon]

Native Oberon [Based on ETH Oberon]
(see http://www.oberon.ethz.ch/downloads/index for current versions)
(see http://www.oberon.ethz.ch/archives/systemsarchive/native_new)
PC Native Oberon [for Intel-compatible PCs]
PC Native Oberon for Dummies [for Windows installation]
Linux-based Native Oberon [LNO]
SharkOberon [for DEC Shark Network Computers, ARM-based]
Native Oberon Alpha [http://www.oberon.ethz.ch/faq/faqnativealfabeta]
Native Oberon Beta [see same link as Alpha]

Versions at http://www.oberon.ethz.ch/archives/languagearchive/genealogy
Oberon
Oberon-V
Oberon X
Active Oberon
Oberon-SA
Active Oberon for .NET
Object Oberon
Oberon-2
Concurrent Oberon
Action Oberon
Oberon-D
Component Pascal

Versions at http://www.ethoberon.ethz.ch/genealsys.html not already above
SPARC-Oberon
MacOberon
DEC-Oberon
RISC Oberon
MS-DOS Oberon
Chameleon Oberon
HP-Oberon
Oberon for Windows
Spirit of Oberon
Hybrid Oberon
Oberon for Linux
Oberon Linux PPC
more versions named according to supporting OS?

Oberon-0 a particular Oberon language/compiler
see https://en.wikipedia.org/wiki/PL/0
Oberon0 implementation of an Oberon-0 compiler (?) or minimal Oberon
system (?)
Oberon0.dsk disk image for bootable Oberon0 installer
(see
http://sourceforge.net/projects/nativeoberon/files/nativeoberon/Oberon
0%20boot%20disk/)

Another acronym observed is OP2, which is a Portable Oberon compiler
by R Crelier

School of Niklaus Wirth: The Art of Simplicity

School of Wirth

Got myself an excellent book on the Art of Simplicity. Niklaus Wirth designed programming langauages like Pascal and sequels like Modula-2 and Oberon.  His style and dedication to simplicity in a clear writing and presentation style made a great impression on me.

This book gives unique insights in what has happened and is still happening in the school of Niklaus Wirth. Excellent book!

From the Back Cover

Niklaus Wirth is one of the great pioneers of computer technology and winner of the ACM’s A.M. Turing Award, the most prestigious award in computer science. He has made substantial contributions to the development of programming languages, compiler construction, programming methodology, and hardware design. While working at ERH Zurich, he developed the languages Pascal and Modula-2. He also designed an early high performance workstation, the Personal Computer Lilith, and most recently the language and operating system Oberon.
While Wirth has often been praised for his excellent work as a language designer and engineer, he is also an outstanding educator – something for which he is not as well known. This book brings together prominent computer scientists to describe Wirth’s contributions to education. With the exception of some of his colleagues such as Professors Dijkstra, Hoare, and Rechenberg, all of the contributors to this book are students of Wirth. The essays provide a wide range of contemporary views on modern programming practice and also illuminate the one persistent and pervasive quality found in all his work: his unequivocal demand for simple solutions. The authors and editors hope to pass on their enthusiasm for simple engineering solutions along with their feeling for a man to whom they are all so indebted.

Contents

Editors: László Böszörményi, Jürg Gutknecht, Gustav Pomberger

Part 1: Niklaus Wirth – a Pioneer of Computer Science
Gustav Pomberger, Hanspeter Mossenbock, Peter Rechenberg
Part 2: Niklaus Wirth and Edsger W. Dijkstra From Programming Language Design to Computer Construction
Niklaus Wirth On the transitive closure of a wellfounded relation
Edsger W. Dijkstra
Part 3: The Teachings of a Scholar as Told by his Pupils – Common Work in Retrospect
Oberon – the Overlooked Jewel Michael Franz
Compiler Construction – The Art of Niklaus Wirth Hanspeter Mossenbock
Medos in Retrospect Svend Erik Knudsen
Lean Systems in an Intrinsically Complex World Peter Schulthess
Learning the Value of Simplicity Stephen W. Gehring
Part 4: New Ways in Education and Research
Compiler Construction versus Lotus Notes: A Strange Battle Jurg Gutknecht
Modules and Components – Rivals or Partners Clemens Szyperski
A Compiler for the Java HotSpot Virtual Machine Robert Griesemer, Srdjan Mitrovic
Designing a Cluster Network Hans Eberle
Programming With Functional Nets Martin Odersky
Part 5: Mastering Simplicity – in the Industry
Lilith meets the World of Business Bernhard Wagner
the Chip Company that made $100M with MODULA-2 Robert Burton, Farrell Ostler, Thom Boyer, Fon Brown, Matt Morrise
FFF97 – Oberon in the Real World Dr. Josef Templ
Part 6: The World According to Wirth – Personal, Anecdotal Reviews
Serendipity Kathleen Jensen
Daily Life with N. WirthJirka Hoppe
Third Millennium Culture Ann Dunki Authors and Editors

 

Niklaus Wirth

niklaus_wirthProfessor Niklaus Wirth is an honered and well respected computer scientist. Very influencal with his work on programming, programming languages and operating systems design. Designer of Pascal, Modula, Oberon, the Lilith computer and more. As a professor at the ETH in Zurich Switzerland he advanced our knowledge and capabilities with computers and their programming.

Wirth not only designed languages, he also designed hardware, combining the strengths of his programming languages with a well suited platform. The first computer is called Lilith, of which about 100 were built around 1980. In 1981 he wrote an article about Lilith: “The Personal Computer Lilith”, on this page you find also photo’s recently made of a surviving and working Lilith computer.