In computer programming, a P-code machine (portable code machine) is a virtual machine designed to execute P-code, the assembly language or machine code of a hypothetical central processing unit (CPU). The term P-code machine is applied generically to all such machines (such as the Java virtual machine (JVM) and MATLAB pre-compiled code), as well as specific implementations using those machines. One of the most notable uses of P-Code machines is the P-Machine of the Pascal-P system. The developers of the UCSD Pascal implementation within this system construed the P in P-code to mean pseudo more often than portable; they adopted a unique label for pseudo-code meaning instructions for a pseudo-machine.

Although the concept was first implemented circa 1966 as O-code for the Basic Combined Programming Language (BCPL) and P code for the language Euler,

Microsoft P-code

As the goal of the company was to release software for all the major platforms and architectures that existed then. Between 1980 and 1982, Microsoft developed an early C compiler that produced P-Code (the C language itself was not standardized and wouldn't be until later in the 80s). The P-Code allowed software to run on most platforms with minimal code change. UCSD Pascal was using a similar approach. This C to P-Code was a success but was very slow. In 1983, Microsoft released the Microsoft C Compiler, MSC, based on a license of the Lattice C compiler for versions 1.0 and 2.0; then, from version 3.0 onward, the MSC was a complete rewrite by Microsoft.

P-code is a name later used by some of Microsoft's intermediate languages. They provided an alternate binary format to machine code. At various times, Microsoft has said P-code is an abbreviation for either packed code or pseudo code.

Some Microsoft P-code flavor, quite different from the one used by the C compiler, was widely used with Visual Basic which had a runtime that included a VM or could be directly compiled to native code. Like other P-code implementations, Microsoft P-code enabled a more compact executable at the expense of slower execution.

Other implementations

See also

  • Bytecode
  • Intermediate representation
  • Joel McCormack, designer of the NCR Corporation version of the p-code machine
  • Runtime system
  • Token threading
  • City & Guilds Mnemonic Code

References

Further reading

  • (NB. Has Pascal sources of the P4 compiler and interpreter, usage instructions.)
  • (NB. Has the P-code of the P4 compiler, generated by itself.)
  • , including packaging and pre-compiled binaries; a friendly fork of the
  • (NB. Especially see the articles Pascal-P Implementation Notes and Pascal-S: A Subset and its Implementation.)