pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-52
TNS Registers
In TAL, you can use a base-address equivalenced declaration to create an identifier
that references a data item at:
•
A positive offset from the beginning of the user data segment (G-relative)
•
A positive or negative offset from the beginning of a procedure’s local data (L-
relative)
•
A negative offset from the beginning of a subprocedure’s local data (S-relative)
pTAL does not support based-address equivalenced declarations. If your code uses
any of the following constructs, you must find other ways to code your algorithms.
In the following declaration, STACK_P references the 16-bit integer that begins twenty
16-bit words from the beginning of the procedure’s local data:
INT stack_p = 'L' + 20;
In the following declaration, MY_GLOBAL references the global 32-bit integer that
begins at word offset 20:
INT(32) my_global = 'G' [20];
In the following declaration, MY_SUBLOCAL references the 16-bit integer variable that
begins four words from the current top of the data stack:
INT my_sublocal = 'S' - 4;
TNS Registers
Guideline: If you must use register operations, localize the register operations in
DEFINEs or procedures.
In TAL, you can use CODE statements to access TNS registers. For example, the
following CODE statement reads the current value of the TNS ENV register:
CODE( RDE );
pTAL does not support CODE statements. In pTAL, you cannot access registers such
as the ENV register.
Avoid accessing TNS registers. For example, use standard TAL constructs
$OVERFLOW, $CARRY, and condition code tests (<, =, >, and so forth) to test
conditions that are reported in the TNS ENV register.
If you must continue to access TNS registers in TAL applications, localize these
accesses by embedding them in a small number of procedures or, if performance is an
issue, in a small number of TAL DEFINEs. By localizing access to registers in
procedures and DEFINEs, you can find these accesses more easily when you begin to
use pTAL and convert them to comparable pTAL constructs. Also, if you must continue
such access when running your program as a TNS process, you can simplify the
process of maintaining a single source.