0 0 defaultprogram.xml Default (empty program, code your own) Squares example (from a PL/0 exercise by Michael Neumann) Squares example (from Susan Stepney, High Integrity Compilation) Calculation of the volume of a sphere (from Peter Grogono, Programming in Pascal)

A PL/0 p-code virtual machine

This page illustrates the behavior of a simple three-register machine specified by Nicklaus Wirth in his book Algorithms + Data Structures = Programs.

Enter the program in the program-code area (or select one of the sample programs). Then click Step to step through it.

A short description of the PL/0 virtual machine and its machine language is available on another page. [Further explanation and commentary would probably be useful, and will be provided eventually.]

Registers

B (base register)
T (stack top register)
Step
P (program counter)
I (instruction register)

Stack

Code area

Some sample programs are available; select one from the list and load it.

Select a program
Load program
Edit code
Done editing code
Address
Op code Load/store Load constant (LIT 0 a) LIT Load variable (LOD level a) LOD Store variable (STO level a) STO Call/return/jump Call procedure (CAL level a) CAL Increment top-of-stack register T (INT 0 a) INT Jump to address A (JMP 0 a) JMP Jump conditional (jump if false) (JPC 0 a) JPC Tests and operations Perform operation A (OPR 0 a) OPR Level Arg return (0)0 negate (1)1 add (2)2 subtract (3)3 multiply (4)4 divide (5)5 odd? (6)6 eq? (8)8 neq? (9)9 lt? (10)10 ge? (11)11 gt? (12)12 le? (13)13 Arg
Comment
Label
Comment
Comment
Insert instruction Insert label Insert comment Delete

Show XML form of machine program

Show XML
Last updated 3 December 2011