pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-14
32-Bit Addresses
32-Bit Addresses
Guideline: Create 32-bit addresses only to reference data in extended data segments.
In TAL, your program can reference all data with a 16-bit address except data in
extended memory, for which you must use a 32-bit address. On TNS architecture, you
can also create 32-bit addresses to reference data in other segment types, such as in
the user data segment.
On native architecture, all addresses are 32 bits except addresses whose address type
is SGBADDR or SGWADDR, which are 16 bits on both TNS and native architectures.
Addresses and Integer Variables
Guideline: Do not store addresses and data in the same variable.
In TAL, you can declare a variable and store both integers and addresses in it.
Example 2-9 on page 2-14 is valid in TAL but not in pTAL.
To be compatible with pTAL, treat every pointer as having an object data type and an
address type. The object data type of a pointer is the data type of the objects that you
reference with the pointer such as INT, STRING, REAL(64), and so forth. The address
type of a pointer describes the addresses that you can store into the pointer.
For example, a STRING pointer that references data in the user data segment must
contain a byte address. Its address type is BADDR.
Address Variables
Guideline: Declare variables that hold addresses to be an address type.
pTAL defines new data types, all of which describe addresses. For details, see
Address-Type Variables on page 3-4.
Note. pTAL supports the ability to use 32-bit addresses to reference data in segments other
than extended data segments, but HP does not guarantee that pTAL will continue to support
this ability.
Example 2-9. Variable Can Store Integer or Address (TAL Only)
INT a[0:9];
INT i;
INT .p1;
INT .p2;
FOR i := 0 to 9 DO
a[i] := 0; ! i holds an integer loop-control variable
i := @p1; ! i holds an address
@p1 := @p2;
@p2 := i;