-

Difference between revisions of "Compiler Structure"

From HI-TECH C for CP/M Fan WIKI(EN)
Jump to: navigation, search
(Created page with "The compiler is made up of several passes; each pass is implemented as a separate program. Note that it is not necessary for the user to invoke each pass individually,...")
 
Line 1: Line 1:
The compiler is made up of several passes; each pass is
+
The compiler is made up of several passes; each pass is implemented  as  a  separate  program.  Note  that it is not necessary for the user to invoke each pass individually,  as the  C  command runs each pass automatically.  Note that the machine dependent passes are named differently for each processor,  for example those with 86 in their name are for the 8086 and those with 68K in their name are for the 68000.
implemented  as  a  separate  program.  Note  that it is not
 
necessary for the user to invoke each pass individually,  as
 
the  C  command runs each pass automatically.  Note that the
 
machine dependent passes are named differently for each pro-
 
cessor,  for example those with 86 in their name are for the
 
8086 and those with 68K in their name are for the 68000.
 
  
 
The passes are:
 
The passes are:
  
CPP The pre-processor - handles macros and conditional com-
+
CPP
pilation
+
:The pre-processor - handles macros and conditional compilation
  
P1   The syntax and  semantic  analysis  pass.  This  writes
+
P1
 +
:The syntax and  semantic  analysis  pass.  This  writes
 
intermediate code for the code generator to read.
 
intermediate code for the code generator to read.
  
CGEN, CG86 etc.
+
CGEN, CG86 etc.:
The code generator - produces assembler code.
+
:The code generator - produces assembler code.
  
 
OPTIM, OPT86 etc.
 
OPTIM, OPT86 etc.
The code improver - may optionally be omitted, reducing
+
:The code improver - may optionally be omitted, reducing compilation  time at a cost of larger, slower code produced.
compilation  time at a cost of larger, slower code pro-
 
duced.
 
  
 
ZAS, AS86 etc.
 
ZAS, AS86 etc.
The assembler - in fact a general purpose macro  assem-
+
:The assembler - in fact a general purpose macro  assem-
 
bler.
 
bler.
  
 
LINK
 
LINK
The link editor - links object files with libraries.
+
:The link editor - links object files with libraries.
  
 
OBJTOHEX
 
OBJTOHEX
This utility converts  the  output  of  LINK  into  the
+
:This utility converts  the  output  of  LINK  into  the appropriate  executable  file format (e.g. .EXE or .PRG or .HEX).
appropriate  executable  file format (e.g. .EXE or .PRG
 
or .HEX).
 
  
The passes are invoked in the order  given.  Each  pass
+
:The passes are invoked in the order  given.  Each  pass reads  a  file  and writes a file for its successor to read. Each intermediate file has a particular format; CPP produces C code without the macro definitions and with uses of macros expanded; P1 writes a file containing a program in an intermediate code; CGEN translates this to assembly code; AS produces object code, a binary  format  containing  code  bytes along  with relocation and symbol information.  LINK accepts object files  and  libraries  of  object  files  and  writes another  object file; this may be in absolute form or it may preserve relocation information and be input to another LINK command.
reads  a  file  and writes a file for its successor to read.
 
Each intermediate file has a particular format; CPP produces
 
C code without the macro definitions and with uses of macros
 
expanded; P1 writes a file containing a program in an inter-
 
mediate code; CGEN translates this to assembly code; AS pro-
 
duces object code, a binary  format  containing  code  bytes
 
along  with relocation and symbol information.  LINK accepts
 
object files  and  libraries  of  object  files  and  writes
 
another  object file; this may be in absolute form or it may
 
preserve relocation information and be input to another LINK
 
command.
 
  
There are also other utility programs:
+
:There are also other utility programs:
  
 
LIBR
 
LIBR
Creates and maintains libraries of object modules
+
:Creates and maintains libraries of object modules
  
 
CREF
 
CREF
Produces cross-reference listings  of  C  or  assembler
+
:Produces cross-reference listings  of  C  or  assembler programs.
programs.
 

Revision as of 09:05, 26 July 2017

The compiler is made up of several passes; each pass is implemented as a separate program. Note that it is not necessary for the user to invoke each pass individually, as the C command runs each pass automatically. Note that the machine dependent passes are named differently for each processor, for example those with 86 in their name are for the 8086 and those with 68K in their name are for the 68000.

The passes are:

CPP

The pre-processor - handles macros and conditional compilation

P1

The syntax and semantic analysis pass. This writes

intermediate code for the code generator to read.

CGEN, CG86 etc.:

The code generator - produces assembler code.

OPTIM, OPT86 etc.

The code improver - may optionally be omitted, reducing compilation time at a cost of larger, slower code produced.

ZAS, AS86 etc.

The assembler - in fact a general purpose macro assem-

bler.

LINK

The link editor - links object files with libraries.

OBJTOHEX

This utility converts the output of LINK into the appropriate executable file format (e.g. .EXE or .PRG or .HEX).
The passes are invoked in the order given. Each pass reads a file and writes a file for its successor to read. Each intermediate file has a particular format; CPP produces C code without the macro definitions and with uses of macros expanded; P1 writes a file containing a program in an intermediate code; CGEN translates this to assembly code; AS produces object code, a binary format containing code bytes along with relocation and symbol information. LINK accepts object files and libraries of object files and writes another object file; this may be in absolute form or it may preserve relocation information and be input to another LINK command.
There are also other utility programs:

LIBR

Creates and maintains libraries of object modules

CREF

Produces cross-reference listings of C or assembler programs.