Download HP Pascal for OpenVMS Language Reference Manual

Transcript
Example A–1 (Cont.) Using Program Sections to Allocate Storage
VAR
Error_Count : [STATIC] INTEGER VALUE 0; {
{
{
Message_Buffer : VARYING [132] OF CHAR; {
BEGIN { Error_Routines }
Error_Count := Error_Count + 1;
Local_Variable := Error_Count;
END;
BEGIN
{
.
.
.
END.
$SDATA$ on OpenVMS I64 }
$DATA$ on OpenVMS Alpha }
$LOCAL on OpenVMS VAX }
Automatic Storage }
$CODE or $CODE$ }
Storage for all variables with static allocation is allocated in $SDATA$,
$DATA$, or $LOCAL. Storage for the executable block of the main program is
allocated in $CODE or $CODE$. Storage for the symbolic constant Message_
String is allocated in $LITERAL on OpenVMS I64 and OpenVMS Alpha
systems and in $CODE on OpenVMS VAX systems. Storage is allocated in the
user-created program section, Error_Routines, for the symbolic constant User_
Error_Message and the executable block of User_Error. Storage for Local_
Variable is in $SDATA$ on OpenVMS I64 systems, $DATA$ on OpenVMS
Alpha systems, and $LOCAL on OpenVMS VAX systems because it was
referred to in a nested block. Storage for Magic_Number is in the usercreated program section, Magic. Since Magic_Number was declared with the
READONLY attribute, the program section has the NOEXE, NOWRT, RD, and
SHR properties.
A.2.4 Allocation Sizes of Variables
For every HP Pascal data type, the compiler calculates the allocation size
required when a variable of the type occurs in either an unpacked or a packed
context. The unpacked size is always represented in bytes, while the packed
size is represented in bits.
The packed size of a variable is the minimum number of bits required to
represent all values of the variable’s type. In general, the compiler uses the
following 32–bit rules to determine the allocation size for a component of a
packed structured variable:
•
A component whose length is 32 bits or fewer is packed into as few bits as
possible and can be unaligned.
A–10 Data Storage and Representation