HP 3000 Manuals

Compiling a Program [ Getting Started as an MPE/iX Programmer Programmer's Guide ] MPE/iX 5.0 Documentation


Getting Started as an MPE/iX Programmer Programmer's Guide

Compiling a Program 

When you have saved the program source code in a file, it must be
compiled; translated into machine readable instructions in a program
file.  The MPE/iX Native Mode language compilers available for this
purpose are HP C/iX, HP Pascal/iX, HP COBOL II/XL, and HP FORTRAN 77/iX.
Commands are available to:

   *   Compile, link, and execute a program, in one command
   *   Compile and link a program, in one command
   *   Compile a program

An overview of these commands is given later in this section.  For
detailed information on them, refer to :

   *   HP C/iX Reference Manual Supplement (31506-90001).

   *   HP Pascal Programmer's Guide (31502-90002).

   *   HP COBOL II/XL Programmer's Guide (31500-90002).

   *   HP FORTRAN 77/iX Programmer's Guide Supplement (31501-90002).

Compiler Input 

Follow the appropriate instructions for the language you are using; HP
C/iX, HP Pascal/iX, HP COBOL II/XL, or HP FORTRAN 77/iX. For example, to
compile a program named MYPROG in HP Pascal/iX, enter:

     :PASXL MYPROG

For further instructions on compiling, refer to:

   *   HP C/iX Reference Manual Supplement (31506-90001).

   *   HP Pascal Programmer's Guide (31502-90002).

   *   HP COBOL II/XL Programmer's Guide (31500-90002).

   *   HP FORTRAN 77/iX Programmer's Guide Supplement (31501-90002).

   *   MPE/iX Commands Reference Manual Volumes 1 and 2 (32650-90003 and
       32650-90364).

Compiler Output 

The compiler can write compiled code in a relocatable object file,
generate a source code listing, and generate an error list.  Unless you
specify differently, the compiler writes the object file to the standard
file $NEWPASS, which is renamed $OLDPASS when the compile is completed
and $NEWPASS is closed.  The compiler writes the source code and error
list to $STDLIST.

Compiler Operation 

The compiler reads a source file as input, performs a translation to
object code, and writes the resulting compiled code in relocatable object
modules.  The number of modules in a file is compiler dependent.  MPE/iX
compilers usually produce one relocatable object module in a relocatable
object file.  The internal structure of a relocatable object module is
common to all compilers that generate Hewlett-Packard Precision
Architecture (HP-PA) code.  A relocatable object module contains a
combination of code and data for all procedures in the source file that
was the compilation unit.  A relocatable object module is the smallest
unit that a compiler can produce or the Link Editor can manipulate.

A source file with several procedures in it compiles all of them into one
relocatable object module.  The procedures within the relocatable object
module cannot be replaced or purged individually.

When a large program is divided into several source files, each one can
refer to external procedures (subroutines or variables that are defined
in another file).  Because MPE/iX compilers process only one source file
at a time, external procedure references cannot be resolved at compile
time.  They are resolved at link time, when all of the program components
are brought together.  The compiler simply assigns a fix-up request
(frequently called a relocatable address) to each external reference,
indicating the relative position of each subroutine or variable in the
relocatable object module.


NOTE A relocatable object module on MPE/iX corresponds to a relocatable binary module (RBM) on MPE V/E, with the following exceptions: * A relocatable object module can contain zero, one, or several procedures, while an RBM represents only one. * A relocatable object module is complete in itself and can stand alone as an independent file, while an RBM can exist only as part of an MPE V/E user subprogram library (USL) or a relocatable library (RL).
To separate relocatable object modules for two procedures into different relocatable object files, you must put the procedures in separate source files and compile them individually. You can gather them together at link time. Figure 3-2 shows an MPE/iX Native Mode compiler producing a relocatable object module.
[]
Figure 3-2. Compiler Producing Relocatable Object Modules A relocatable object module is an independent file. It may not require resources such as relocatable libraries (RLs) and links to other relocatable object modules, although these are made, when necessary, at link time. External resources (usually system routines) are acquired at run time. A relocatable object module contains the following information, described in detail in the subsections below: * Compiled code (machine instructions) for all procedures in the source file * Information on data variables to be used * External references (resources required to run the program) The compiler generates a symbol table in each relocatable object module. It lists all the procedures and variables that are defined in the module and may be required by other modules at link time and all those that are referenced in the module, but not defined there. The compiler assigns a fix-up address to each defined subroutine or variable symbol, indicating its position relative to the beginning of the module. Compiled Code. A compiler segregates code and data into separate areas in a relocatable object module. The individual compiler determines how compiled code is organized within it and the content is compiler dependent. Data constants are stored in the relocatable object module along with code and, thus, are non-modifiable. To change compiled code, you must recompile the entire relocatable object module. Data Variables Information. A relocatable object module contains information on data requirements. Usually, it describes data types and required data space. The exact type of information is compiler dependent. It is used when initialization of variables is requested or when the data space has a common variable, which is a variable that several pieces of code can share. Unresolved References. Because a compiler processes one source file at a time, it cannot resolve external references, determine parameter compatibility with them, or analyze actual data. This must be resolved at link time or run time. The compiler simply lists external references required for execution in a symbol table located in the relocatable object module, allowing you to compile a program in several pieces by separately compiling several source files. The symbol table lists all subroutines and variable names that are defined by the relocatable object module. Compiler Libraries. Compiler libraries are used at run time by every program. On MPE/iX, they are stored in a library named XL.PUB.SYS. Command to Compile Only. The command to compile a program (without linking, loading, and running it) is the command, followed by an optional list of file names. The commands are: :CCXL :COB85XL :FTNXL :PASXL If you omit a file from the list, a standard default file is used. The standard default files are: $STDIN textfile $NEWPASS objectfile $STDLIST listfile If you fail to supply a relocatable object module, a compiler opens a new file named $NEWPASS and designates it to be a relocatable object module. At the end of the compilation, $NEWPASS is automatically renamed $OLDPASS and saved. Unless you designate differently, the compiler listing produced by the compilation is output to your job or session list device, so you can see any errors. You can obtain two types of output from a compiler, aside from the compiler listing of errors: * Source code translation of the output to a relocatable object module. * Source listing, with various map and table options. Compiler Control. If you wish only to compile a program, without linking and running it, you can use the "compile only" command for the appropriate language. These commands allow you to provide several optional parameters that specify the name of the textfile (source file), objectfile (relocatable object module), and listfile. The text file contains the source code for the program. The relocatable object module will contain the output from the compile. The listfile, which is usually on a terminal or printer, will reflect the progress of the compile. When source code has been successfully compiled and you have an error-free relocatable object module, you are ready to link a program file from information in one or more relocatable object modules. A software product called Link Editor performs this operation.


MPE/iX 5.0 Documentation