Section "control"

The concept of a π-WAM embraces a fusion of a process (π) calculus and a Warren Abstract Machine (WAM). Optimized for speed the WAM is very primitive, but already supports all ISO control constructs, plus 32-bit integer basic arithmetic and the between/3 generator. The used Hack instructions are as well 32-bit integer values:

 
Figure 1: Hack Instruction Format

We have borrowed Hack from Nisan & Schocken, The Elements of Computing Systems. The book shows an instruction format with 2 different instruction types, A instructions and C instructions. We do not strictly make this distinction in our take. There is a blend represented inside the 4-bit wide “Mode” field of each instruction. The compilation is done as follows:

 
Figure 2: Hack Compilation Flow

The compilation of Prolog control constructs such as conjunction (,)/2, disjunction (;)/2, if-then-else (->)/2 and the cut !/0, makes reuse of the Dogelog VM front end. This front does a surface compilation, and replaces if-then-else (->)/2 and the cut !/0, by the Dogelog built-ins ‘$MARK’/1, ‘$CUT’/1, etc.. Which are then compiled to Hack instructions.