TAL Reference Manual

Statements
TAL Reference Manual526371-001
12-39
Usage Considerations
Usage Considerations
The compiler associates each identifier specified in a USE statement with an index
register starting with R[7] down to R[5]. Thus, you can use at most three reserved
registers at a time.
Statements that appear between a USE statement and a corresponding DROP
statement or the end of the procedure or subprocedure can access the reserved index
register. If a global or local item with the same identifier as a USE identifier already
exists, the compiler issues an error message.
You can, for example, use a reserved index register to optimize a FOR statement as
described in the description of the FOR statement. Before referring to the identifier of a
reserved index register, be sure to assign a value to it.
You can also assign a value to a reserved index register and then pass the index
register content as an implicit parameter to a procedure or subprocedure. This
practice, however, is not portable to future software platforms. For more information,
see the
TAL Programmers Guide.
If evaluation of an expression overwrites the value in a reserved register, the compiler
issues a diagnostic message. For example, multiplication of two FIXED values will
overwrite the reserved register.
To determine whether using the index register is beneficial, you can use the
INNERLIST directive and then review the code generated by statements in the range
of a USE statement.
If the compiler needs an index register and none is available, the compiler emits a
diagnostic message.
When you are finished using a reserved index register, release (or drop) it by issuing a
DROP statement, as described in DROP Statement
on page 12-20.
Examples of USE Statements
1. This example reserves two index registers. The compiler associates each identifier
with an index register, starting with R[7]:
USE a_index; !Reserve R[7]
USE b_index; !Reserve R[6]
a_index := 0;
b_index := -1;
2. This example contrasts a standard FOR loop with an optimized FOR loop (if no
procedure or function calls occur within the loop):