If there is sufficient commercial interest, a hardware implementation of the CPU specification may be built (e.g., the Pascal MicroEngine or a version of a Java processor).
This separation makes it possible to detach the development of a P-code interpreter from the underlying machine code compiler, which has to consider machine-dependent behaviour in generating its bytecode.
Conversely, the two-step interpretation of a P-code-based program leads to a slower execution speed, though this can sometimes be addressed with just-in-time compilation, and its simpler structure is easier to reverse-engineer than native code.
In the early 1980s, at least two operating systems achieved machine independence through extensive use of P-code [citation needed].
The UCSD p-System, developed at The University of California, San Diego, was a self-compiling and self-hosting operating system based on P-code optimized for generation by the Pascal language.
The language Go uses a generic, portable assembly as a form of p-code, implemented by Ken Thompson as an extension of the work on Plan 9 from Bell Labs.
The NP (the new pointer) register points to the top (lowest used address) of the heap.
Stack frames look like this: The procedure calling sequence works as follows: The call is introduced with where n specifies the difference in nesting levels (remember that Pascal supports nested procedures).
Niklaus Wirth specified a simple p-code machine in the 1976 book Algorithms + Data Structures = Programs.