3.1 Compiling Your Program into P-Code

You can take advantage of p-code without making any changes to your source code. You need only specify p-code as the target code when you compile your program from within the Programmer's Workbench or from the command line.

Selecting P-Code from Within the Programmer's WorkBench

You optimize with p-code from within the Programmer's WorkBench (PWB) integrated environment by using one of PWB's predefined project templates.

From the Options Menu, choose Project Templates, and then Set Project Template. In the Set Project Template dialog box, make sure that C or C++ is selected in the Run-Time Support list. Then move to the Project Template list and select either DOS P-Code EXE or Windows P-Code EXE.

The following section describes the optimizations implied when you choose to build a p-code executable.

Selecting P-Code from the Command Line

Specify /Oq as the first option on the command line. For example, to make MYPROG.C into the smallest executable file possible, type:

CL /Oq MYPROG.C

This command compiles MYPROG.C into p-code and, besides invoking LINK, invokes the Make P-Code (MPC) utility, which is required to produce a p-code executable file.

On average, a program compiled into p-code is about 40 percent smaller than a program compiled into machine code, excluding the size of the p-code interpreter. (For more information about the MPC utility, see “Controlling the P-Code Build Process”).

Compiling with the /Oq option or selecting p-code from within the Programmer's WorkBench implies the following optimizations:

Turn P-Code Quoting On (/Of)

Enable Frame Sorting (/Ov)

Enable Post-Code Generation Optimization (/Oo)

If you want to compile only selected portions of your program into p-code, you can do so by making changes to your source code or by using the relevant compiler options. These procedures are described in “Fine-Tuning Your P-Code Program,”.

In addition, if you want greater control over the compilation and linking process, you can execute MPC individually, instead of having CL invoke it.