Compiling, Linking, and Running Your Program [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
Compiling, Linking, and Running Your Program
To make your HP Pascal program a valid MPE/iX process, you must compile,
link, and run it.
The HP Pascal compiler compiles your source program, which is in a
textfile. It translates your source code to binary form and stores it in
an object file or in an RL.
The MPE/iX linker prepares the object file for execution by binding the
procedures in the object modules together and defining the initial
requirements of the user data stack.
The MPE/iX operating system allocates space for the program, binds its
external routines to it, and runs it. (The external routines are in
executable libraries).
Additionally, the compiler looks for a system-wide file called
PASCNTL.PUB.SYS. If the file exists and is not empty, the compiler opens
and reads the file.[REV BEG] The file should contain only compiler
options[REV END] and comments. If there is anything else in the file,
the compiler emits an error message. If the file is empty, which is the
default, the compiler does not attempt to open it. For more information
on the system-wide file, refer to the section on compiler options in the
HP Pascal/iX Reference Manual.
Figure A-1 shows how a source program (in a textfile) becomes a
running program on MPE/iX.
[REV BEG]
Figure A-1. How Source Code Becomes a Running Program on MPE/iX
[REV END]
This section explains:
* The MPE/iX command files that perform the steps shown in Figure
A-1 .
* How to run the HP Pascal compiler with the MPE/iX command :RUN
PASCALXL.PUB.SYS.
* How to pass run-time parameters to your program.
Command Files
Table A-10 shows the MPE/iX command files that you can use to perform
the steps shown in Figure A-1 . Each command or command file in the
right-hand column of Table A-1 performs the step or steps in the
left-hand column (for example, the command :PASXL performs the
compilation step, the command :PASXLLK performs the compilation and
linking steps, and the command :PASXLGO performs the compilation,
linking, and running steps).
Table A-10. MPE/iX Command Files That Compile,
Link, and Run a Program
-------------------------------------------------------------------
| | |
| Steps | MPE/iX Commands |
| | or Command Files |
| | |
-------------------------------------------------------------------
| | |
| To Compile | :PASXL |
| | |
-------------------------------------------------------------------
| | |
| To Link | :LINK |
| | |
-------------------------------------------------------------------
| | |
| To Run | :RUN |
| | |
-------------------------------------------------------------------
| | |
| To Compile and Link | :PASXLLK |
| | |
-------------------------------------------------------------------
| | |
| To Compile, Link, and Run | :PASXLGO |
| | |
-------------------------------------------------------------------
If you plan on linking as a separate step and would like more information
on linking, refer to the HP Link Editor/XL Reference Manual.
Table A-11 gives the MPE/iX command files that are equivalent to the
MPE V commands PASCAL, PASCALPREP, and PASCALGO. (Each command file name
has group "pub" and account "sys"--see "File Names" .)
Table A-11. Equivalent MPE V Commands and MPE/iX Command Files
-------------------------------------------------------------------
| | |
| MPE V Command | MPE/iX Command File |
| | |
-------------------------------------------------------------------
| | |
| :PASCAL | :PASXL |
| | |
-------------------------------------------------------------------
| | |
| :PASCALPREP | :PASXLLK |
| | |
-------------------------------------------------------------------
| | |
| :PASCALGO | :PASXLGO |
| | |
-------------------------------------------------------------------
Syntax
PASXL [textfile][,[objectfile][,[listfile][,libfile]]][; INFO="options"]
PASXLLK [textfile][,[progfile][,[listfile][,libfile]]][; INFO="options"]
PASXLGO [textfile][,[listfile][,libfile]][; INFO="options"]
Parameters
textfile The name of the textfile that contains the source code to be
compiled.
If you are running HP Pascal from your terminal, textfile is
usually a file, but the default is $STDIN. $STDIN is the
current input device, usually your terminal.
When textfile is the terminal, you can enter source code
interactively in response to the prompt ">." When you have
entered every line of your source code, type a colon (:) in
response to the prompt.
The source code to be compiled can be either a program or a
list of modules. A list of modules has the syntax:
module1[; module2 [; ... [; modulen]]... ]
where module1 through modulen are module bodies.
objectfile The name of the object file or RL on which the compiler
writes the binary form of the source code that is in
textfile. The default is $OLDPASS or $NEWPASS.
listfile The name of the file on which the compiler writes the
program listing. It can be any ASCII file. The default is
$STDLIST. $STDLIST is usually the terminal if you are
running HP Pascal from a terminal; it is usually the job
spool file if you are running a batch job.
If your terminal is both textfile and listfile, the compiler
does not write the program listing on the terminal. If this
is a permanent disk file, excess space is released with the
CRUNCHED close option. See "Additional Features"
earlier in this appendix.
If listfile is $NULL or a file other than $STDLIST, the
compiler displays lines that contain errors on $STDLIST.
options A string of 132 or fewer characters, whose value is a list
of compiler options. The compiler encloses the list in
dollar signs and inserts it before the first line of code in
textfile. The default is the empty string.
progfile The name of the program file on which the MPE/iX linker
writes the linked program. The default is $NEWPASS.
libfile The name of the Pascal library file that the compiler
searches if a search path is not specified with the compiler
option SEARCH. The default is PASLIB in your group and
account.
:RUN PASCALXL.PUB.SYS
The HP Pascal/XL compiler is a program file named PASCALXL.PUB.SYS. You
can use the MPE/iX command :RUN to execute PASCALXL.PUB.SYS (that is, to
invoke the HP Pascal/iX compiler).
The compiler files and their defaults are:
File Default
Source file $STDIN
Object file $OLDPASS or $NEWPASS
Listing file $STDLIST
Library file PASLIB
To override the defaults:
1. Use the MPE/iX command :FILE to equate the nondefault file with
its formal file designator (the :FILE parameter formaldesignator).
Use one :FILE command for each nondefault file.
2. Tell the MPE/iX command :RUN which files are not to be defaulted
by passing the appropriate value to its PARM parameter.
The compiler files and their formal file designators are:
Compiler File Formal File Designator
Source file PASTEXT
Object file PASOBJ
Listing file PASLIST
Library file PASLIB
Table A-12 lists the possible values for the PARM parameter and gives
their meanings.
Table A-12. PARM Values and Their Meanings
---------------------------------------------------------------------------------
| | |
| PARM Value | Means "File equations exist for the following |
| | files:" |
| | |
---------------------------------------------------------------------------------
| | | | |
| | Object | Listing | Source |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| 0 * | | | |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| 1 | | | * |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| 2 | | * | |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| 3 | | * | * |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| 4 | * | | |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| 5 | * | | * |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| 6 | * | * | |
| | | | |
---------------------------------------------------------------------------------
| | | | |
| 7 | * | * | * |
| | | | |
---------------------------------------------------------------------------------
* PARM=0 is equivalent to the command :PASXL (without parameters).
Example
:RUN PASCALXL.PUB.SYS
:FILE PASTEXT=Program1
:FILE PASOBJ=Object1
:FILE PASLIST=List1
:FILE PASLIB=Library1
:RUN PASCALXL.PUB.SYS;PARM=7;INFO="TABLES ON"
:FILE PASTEXT=Program2
:FILE PASLIST=List2
:RUN PASCALXL.PUB.SYS;PARM=3
:FILE PASLIST=List3
:FILE PASOBJ=Object3
:RUN PASCALXL.PUB.SYS;PARM=6;INFO="TABLES ON,TITLE 'Program 3'"
It is an error if you specify in the :RUN command that the compiler not
use the default for one of the compiler files, and you do not provide a
file equation for that file.
Example
:FILE PASTEXT=Program2
:FILE PASLIST=List2
:RUN PASCALXL.PUB.SYS;PARM=7
The above command sequence causes the compilation to abort with an error
because PARM=7 specifies that the :RUN statement not default the source,
listing, or object file and no file equation is provided for the object
file.
Run-Time Parameters
You can pass the run-time parameters PARM and INFO to your program with
the RUN command. For each parameter that you want your program to
access, you must:
* Specify a program parameter in the program heading (the position
of the variable is not important).
* Declare the program parameter as a global variable.
The program parameter that corresponds to PARM must be of type shortint.
The program parameter that corresponds to INFO must be of type string or
PAC.
MPE/iX checks the ranges of the actual program parameters for PARM and
INFO if the RANGE compiler option is ON when the compiler encounters the
first line of the statement part of the main program. (For more
information on the RANGE compiler option, see the
HP Pascal/iX Reference Manual.)
Example
If the progfile named ex1 contains code for the program:
PROGRAM example_1 (parm,info);
VAR
parm : integer;
info : PACKED ARRAY [1..255] OF char;
BEGIN
END.
then the command:
:RUN ex1; PARM=3; INFO="abc"
assigns the value 3 to parm and the value abc to info before executing
the program example_1.
MPE/iX 5.0 Documentation