HP Pascal [ COMMUNICATOR 3000/XL - REL. 2.0 (A.30.00) ] MPE/iX Communicators
COMMUNICATOR 3000/XL - REL. 2.0 (A.30.00)
HP Pascal
by Sue Kimura
Data and Languages Division
Several compiler options have been added to HP Pascal. These options
are:
* CALL_PRIVILEGE
* EXEC_PRIVILEGE
* INCLUDE_SEARCH
* MAPINFO
* STDPASCAL_WARN
* VOLATILE
CALL_PRIVILEGE AND EXEC_PRIVILEGE
The CALL_PRIVILEGE and EXEC_PRIVILEGE compiler options allow routines to
call and execute privileged mode routines.
The CALL_PRIVILEGE option specifies the lowest privilege level at which a
calling routine must be executing when it invokes the routine to which
CALL_PRIVILEGE is applied.
The EXEC_PRIVILEGE option specifies the privilege level at which a
routine will execute.
Syntax
________________________________________________________________________
| |
| $CALL_PRIVILEGE n$ |
| $EXEC_PRIVILEGE n$ |
________________________________________________________________________
The n parameter is an integer in the range 0..3, with 0 being the most
privileged level and 3 the least privileged level. Privilege level 3 is
the level at which user programs normally execute.
These options appear after the reserved word PROCEDURE or FUNCTION, and
before the body of the routine.
The compiler option STANDARD_LEVEL 'EXT_MODCAL' is required to use these
options.
It should be noted that when these options are specified, a routine with
a lower privilege level will abort with a data memory protection trap if
it calls a routine with a higher privilege level.
Example
$STANDARD_LEVEL 'EXT_MODCAL'$
PROGRAM p;
PROCEDURE proc1 $EXEC_PRIVILEGE 1$ (
VAR i : integer); external;
PROCEDURE proc2 $CALL_PRIVILEGE 2$
$EXEC_PRIVILEGE 1$ (
VAR i : integer); external;
BEGIN
...
END.
Procedure proc1 executes at privilege level 1. Any routine calling proc1
must be executing at privilege level 0 or 1. A privilege level 2 or 3
routine will abort if it calls proc1.
Procedure proc2 executes at privilege level 1 and any routine calling
proc2 must be executing at privilege level 0, 1 or 2. A privilege level
3 routine will abort if it calls proc2.
INCLUDE_SEARCH
The INCLUDE_SEARCH compiler option is used in conjunction with the
INCLUDE compiler option. It is used to set or modify the search path
used by the compiler to find included files.
Syntax
_______________________________________________________________________
| |
| $INCLUDE_SEARCH '[+] string [, string ]...'$ |
_______________________________________________________________________
The string parameter specifies a path to be searched for an included
file. It is called the include-search path. The "+" parameter, if
specified, appends this include-search path to the end of the existing
include-search path. If omitted, this include-search path replaces the
existing include-search path.
Example
$INCLUDE_SEARCH '&, .declfe.official, .declfe.xl12'$
program p;
$INCLUDE 'globals'$
BEGIN
...
END.
The compiler searches for the included file globals by looking
successively for it under each file name modification specified by the
include-search path. The search stops at the first successful open of
the file in the include-search path.
In this example, it will look successively for the following files:
* globals
* globals.declfe.official
* globals.declfe.xl12
Note that the compiler first attempts to open the file globals in the
current group and account of the user session or job because the first
string of the include-search path is "&".
MAPINFO
The compiler option MAPINFO displays allocation and alignment information
for array and record types.
Syntax
________________________________________________________________________
| |
| $MAPINFO ON | OFF$ |
________________________________________________________________________
The default for the MAPINFO option is OFF.
The information printed with the MAPINFO option is the same as that
printed with the TABLES ON option. However, it is printed when the type
is declared instead of at the end of the scope in which the type is
declared. In addition, the minimum alignment of the structured type is
printed.
Example
$MAPINFO ON$
PROGRAM p;
TYPE
rec = RECORD
f1 : integer;
f2 : integer;
REC MAX RECORD SIZE = x8 BYTES
F1 x0.0 @ 4.0
F2 x4.0 @ 4.0
MIN ALIGNMENT = x4 BYTE
END;
...
The numbers preceded by the symbol "x" are in hexadecimal notation.
The above example shows that the record type rec requires a total of 8
bytes of storage. Field f1 is allocated from byte 0 of the record and
requires 4 bytes of storage. Field f2 is allocated from byte 4 of the
record and it also requires 4 bytes of storage.
STDPASCAL_WARN
When compiling at standard level ANSI or ISO a new error message, "THIS
FEATURE DOES NOT CONFORM WITH THE ANSI/ISO STANDARD", is now issued for
features in HP Pascal which do not conform to the ANSI/ISO standard.
This message is issued when the compiler option ANSI ON, STANDARD_LEVEL
'ANSI', or STANDARD_LEVEL 'ISO' is specified.
To have warnings rather than errors issued the compiler option
STDPASCAL_WARN is needed.
Syntax
________________________________________________________________________
| |
| $STDPASCAL_WARN ON | OFF$ |
________________________________________________________________________
The default for the STDPASCAL_WARN option is OFF.
Example
$STANDARD_LEVEL 'ANSI'$
PROGRAM p;
VAR
lr : longreal;
^
**** ERROR # 1 THIS FEATURE DOES NOT CONFORM WITH THE ANSI/ISO STANDARD (044)
BEGIN
END.
$STDPASCAL_WARN ON$
$STANDARD_LEVEL 'ANSI'$
PROGRAM p;
VAR
lr : longreal;
^
**** WARNING # 1 THIS FEATURE REQUIRES $STANDARD_LEVEL 'HP_PASCAL' (539)
BEGIN
END.
VOLATILE
The VOLATILE compiler option is applied to a variable to specify that the
memory location associated with the variable may be modified by other
processes. It is a signal to the code generator that the volatile
variable must always be loaded from and stored to memory.
Syntax
________________________________________________________________________
| |
| $VOLATILE$ |
________________________________________________________________________
The compiler option VOLATILE is allowed after the ":" in a VAR
declaration. It is also allowed after a "^" in a pointer type or
variable declaration.
Example
TYPE
ptrtype = ^$VOLATILE$ rectype;
VAR
intptrr : ^$VOLATILE$ integer;
recvar : $VOLATILE$ rectype;
The following program shows the use of a volatile variable. With
optimization on, this program will loop infinitely without the VOLATILE
option on the variable stopped.
Example
$OPTIMIZE ON$
PROGRAM show_volatile;
VAR
mask,
oldmask,
oldplabel : integer;
i,
j : integer;
stopped : $VOLATILE$ boolean;
PROCEDURE xaritrap; intrinsic;
PROCEDURE trap;
BEGIN
stopped := true;
END;
BEGIN
mask := 3;
xaritrap (mask,baddress(trap), oldmask, oldplabel);
i := maxint;
j := 5;
REPEAT
i := i div j;
j := j - 1;
UNTIL stopped;
END.
The VOLATILE option should be used judiciously because it slows down the
execution of a program.
MPE/iX Communicators