pTAL Guidelines for TAL Programmers

Coding Guidelines
pTAL Guidelines for TAL Programmers527256-002
2-26
Stack Marker Accesses Using Based-Address
Equivalenced Declarations, Indexing, and Pointers
Stack Marker Accesses Using Based-Address Equivalenced
Declarations, Indexing, and Pointers
Guideline: Do not read or write the contents of the stack marker.
In TAL, you can use base-address equivalencing to reference information stored in the
TNS stack marker, which describes the caller’s environment. The stack marker
contains a copy of the P, ENV, and L registers at the time the currently executing
procedure was called.
pTAL does not support base-address equivalencing and reports a syntax error if you
include a base-address equivalenced declaration in your program. If your TAL program
uses base-address equivalenced declarations, find another way to ascertain this
information, such as having the caller pass information to the called routine in
parameters.
In TAL, you can also reference the stack marker by storing an appropriate value in a
pointer or by using negative indexing. Example 2-25 on page 2-27 has the same effect
as Example 2-24 on page 2-26.
Example 2-24. Using Base-Address Equivalenced Declarations to Access Stack
Marker (TAL Only)
STRUCT env_layout;
BEGIN
BIT_FILLER 8;
UNSIGNED(1) trap_enable;
BIT_FILLER 7;
END;
PROC p;
BEGIN
INT .env_reg(env_layout) = 'L'[-1];
IF env_reg.trap_enable THEN ! Test if caller had
BEGIN ! traps enabled
...
END;
END;