User guide
Chapter 8
The Design of OCODE
BCPL was designed to be a portab l e language wit h a compiler that is easily transfe r r ed
from machine to machine. To help to achieve this, the compiler is struc t ur ed as shown
in figure 8.1 so that the codegenerator (CG), which is inherently machine dependent, is
separated fr om the rest of the compiler. The front end of the compiler performs syntax
analysis producing a parse tree (Tree ) whi ch is then transl at ed by the translation phase
(TRN) to produce an intermediate form (OCODE) suitable for code generation.
LEX SYN Tree TRN OCODE CG
Target
code
BCPL
Figure 8.1: The structure of th e compiler
8.1 Representat io n of OCODE
Since OCODE is output by TRN to be read in by CG, there is little need for it to
be readable by humans and so is encoded as a sequence of integers which, in the
current Cintcode implementation the OCODE is buffered i n memory, however if the
compiler is not given the TO argument it does not invoke the codegenerator but, instead,
outputs the OCODE data to the file ocode in text form as a sequ enc e of signed decimal
numbers. Thi s numerical representation of OCODE can be transformed to a more
readable mnemonic form using the procode commands, described on page 120. As an
145