TAL Programmer's Guide

Appendix C Improving Performance
096254 Tandem Computers Incorporated C–1
Although the TAL compiler is a one-pass compiler and is subject to certain limitations
inherent in this characteristic, it generates efficient object code for the target computer.
If optimum run-time speed is important, however, you can maximize efficiency by
following the guidelines given in this appendix.
General Guidelines The following guidelines describe general practices for achieving efficient code:
Code programs as cleanly and clearly as possible. Provide structured source code
and adequate documentation in the source listing.
Debug the programs to ensure that they work properly.
Analyze the programs using performance analysis tools to determine where
inefficiencies occur.
Based on the analysis, change procedures that require modification. Provide
comments that describe the changes and why you made them.
The following guidelines apply to addressing, indexing, and arithmetic operations.
Addressing Guidelines You can use direct and indirect addressing in various ways.
Direct Addressing Although direct addressing is limited in the amount of memory it can reference, it is
more efficient than indirect addressing. Thus, you should use direct addressing
whenever possible.
For example, suppose a procedure expects a reference parameter that is used heavily
in calculations within that procedure before it returns a value to the caller. In the
procedure, move the value in the indirectly addressed parameter to a local directly
addressed storage area and then use that copy in the calculations. At the end of the
procedure, store the result in the original parameter, which is returned. Although
initially a slight overhead results from copying from parameter to local variable back
to parameter, overall execution speed is improved because:
Indirect addressing is used only twice (once in parameter passing and once in
returning the value).
All other references use direct addressing.
Indirect Addressing Indirect arrays, indirect structures, and pointers you declare provide equivalent
operation. The advantage of indirect arrays and indirect structures is that the compiler
provides a pointer for the array or structure, allocates the data or structure, and
initializes the pointer to the beginning of the array or structure. To use pointers you
declare, you must initialize the pointer and manage allocation of the data to which the
pointer points.
Extended Addressing The compiler emits shorter instruction sequences if it can place INT and STRING
extended pointers in locations G[0] through G[63] or L[1] through L[63], so you should
declare these pointers before you declare other global and local declarations.