83% found this document useful (6 votes)
7K views

P Code Compiler

P-code compilers convert source code into an intermediate format called p-code that can be interpreted on any machine with a p-code interpreter. This allows software portability across different computers. The p-code is compiled from source code and then executed by a p-code interpreter. While interpretation may be slower than machine code, including some machine language subroutines can improve performance at the cost of losing some portability.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
83% found this document useful (6 votes)
7K views

P Code Compiler

P-code compilers convert source code into an intermediate format called p-code that can be interpreted on any machine with a p-code interpreter. This allows software portability across different computers. The p-code is compiled from source code and then executed by a p-code interpreter. While interpretation may be slower than machine code, including some machine language subroutines can improve performance at the cost of losing some portability.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

P-CODE COMPILERS

P-Code compilers (Pseudo code compilers) are very similar in concept to interpreters. In,
both cases, the source program is analyzed and converted into an intermediate form, which is then
executed interpretively. With a P-Code compiler, however, this intermediate form is the machine
language for a hypothetical computer, often called as pseudo-machine or P-Machine. The process
of using such a P-Code compiler is illustrated in the figure. The source program is compiled, with
the resulting object program being in P-Code. This P-Code program is then read and executed
under the control of a P-Code interpreter.

The main advantage of this approach is portability of software. It is not necessary for the
compiler to generate different code for different computers, because the P-Code object programs
can be executed on any machine that has a P-Code interpreter.

SOURCE
PROGRAM

COMPILE P-CODE
COMPILER

OBJECT PROGRAM
(P - CODE)

P-CODE
EXECUTE INTERPRETE
R

TRANSLATION AND EXECUTION USING A P-CODE COMPILER

The design of a P-Machine and the associated P-Code is often related to the requirements
of the language being compiled. This is particularly useful on machines with severely limited
memory size. Obviously the interpretive execution of a P-Code program may be much slower than
the execution of the equivalent machine code. If execution speed is important, some P-Code
compilers support the use of machine language subroutines. By rewriting a small number of
commonly used routines in machine language, rather than P-Code, it is often possible to achieve
substantial improvements in performance. Of course, this approach sacrifices some of the
portability associated with the use of P-Code compilers.

You might also like