HP 3000 Manuals

HP FORTRAN 77/iX Storage Assignment [ HP FORTRAN 77/iX Programmer's Guide ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Programmer's Guide

HP FORTRAN 77/iX Storage Assignment 

This section describes the 900 Series HP 3000 computer hardware
architecture as it relates to the placement of FORTRAN 77 data objects.
This section also describes the actions of the compiler to assign data
areas to FORTRAN 77 variables and common blocks.  Refer to the HP FORTRAN 
77/iX Reference for information on data formats of the FORTRAN 77 data
types.

Memory Areas 

A compiled program uses the following memory areas:

   *   Code

   *   Stack

   *   Data

Each area has different characteristics, as described below.

Code Area.   

The code area is used for the machine instructions and constants
generated by the compiler.  One code area is generated for each program.
The maximum size of a code area is 230 bytes.

Stack Area.   

The stack area is used for any variables local to a particular routine
and for any variables that are passed from one routine to another.  Note
the following about stack areas:

   *   The size of the stack area is system dependent.  For MPE/iX, the
       maximum size of the stack and data area combined is 1 073 741 824
       bytes.

   *   The stack area must be in memory for the program to execute.

   *   Access to the local variables in the stack area is faster than the
       access to passed parameters.

Data Area.   

The data area is normally used for variables that are in common, saved
variables, and initialized variables.  In general, accessing data from
this area requires two instructions, as opposed to one instruction for
accessing data from the stack area.

The stack area is dynamically allocated; thus variables that must be
accessed from multiple subprograms (such as those in common) and
variables that must retain their values across multiple invocations of a
subprogram (such as those that are saved) must be placed in the data
area.

The size of the data area is system dependent.  For MPE/iX, the maximum
size of the stack and data area combined is 1 073 741 824 bytes.

Memory Area Assignment 

This section describes how variables and common blocks are assigned to
the memory areas.


NOTE The location field from the TABLES ON compiler directive lists each data object's assigned memory area. Use this directive if there is any doubt about the location of a data object.
Local Variables. Uninitialized local variables are normally assigned to the stack area. Variables that are initialized with a DATA statement, such as DATA var /3.2/ are assigned to the data area. This allows the compiler to preassign values to these variables statically at link time. If the variables were placed in the stack area, they would have to be reinitialized each time the subprogram in which they were declared was entered. Saved Variables. When a local variable is specified in a SAVE statement, such as SAVE var the variable is assigned to the data area, not to the stack area. This allows the variable to retain its value over multiple invocations of the subprogram in which it is declared. When you specify $SAVE_LOCALS [ON] all local variables are saved and thus are moved from the stack area to the data area. Common Blocks. The compiler places both named and unnamed common blocks in the data area. The Link Editor matches the names of the common blocks declared in different subroutines or functions and determines where to place the blocks in the data area. Summary of the Memory Area Assignment. Table 1-4 summarizes the assignment rules of the memory areas. Table 1-4. Summary of Memory Area Assignment -------------------------------------------------------------------------------- | | | | | | Description | Code | Stack | Data | | | Area | Area | Area | | | | | | -------------------------------------------------------------------------------- | | | | | | Local variables | | X | | | | | | | -------------------------------------------------------------------------------- | | | | | | Variables with $SAVE_LOCALS specified | | | X | | | | | | -------------------------------------------------------------------------------- | | | | | | Variables specified with a SAVE statement | | | X | | | | | | -------------------------------------------------------------------------------- | | | | | | Variables specified with a DATA statement | | | X | | | | | | -------------------------------------------------------------------------------- | | | | | | Common blocks | | | X | | | | | | -------------------------------------------------------------------------------- | | | | | | Formats | | | X | | | | | | -------------------------------------------------------------------------------- | | | | | | Constants | X | | | | | | | | -------------------------------------------------------------------------------- | | | | | | Machine instructions | X | | | | | | | | -------------------------------------------------------------------------------- | | | | | | Compiler temporaries | | X | | | | | | | -------------------------------------------------------------------------------- | | | | | | Passed addresses | | X | | | | | | | --------------------------------------------------------------------------------


MPE/iX 5.0 Documentation