Object Code Accelerator Manual

Preparing Your Program for TNS/E Systems
Object Code Accelerator Manual528144-003
2-13
Data Alignment in TNS and Accelerated Code
nbits := 35; ! Shift value of 35-bits
q := p >> nbits; ! On TNS systems,
! same as p >> 16, q = -1
! On TNS/E systems,
! same as p >> (35-32), q = -16
Data Alignment in TNS and Accelerated Code
This section describes the data alignment requirements for TNS code and the OCA. It
also describes how to use the Misalignment Tracing Facility diagnostic tool.
On TNS systems, a word is 16 bits. The TNS instruction set includes data access
instructions that use 32-bit byte addresses that must be even-byte aligned (that is,
aligned 0 modulo 2) for correct operation. This requirement remains even after the
OCA translates TNS code into RISC code. In TNS mode and accelerated mode,
addresses that are odd-byte aligned (that is, aligned 1 modulo 2) are called misaligned.
TNS processors consistently “round down” misaligned addresses (that is, they ignore
the low-order bit).
TNS/E processors handle the misaligned addresses of TNS programs inconsistently,
rounding down some but not others and behaving differently in TNS mode and
accelerated mode. These problems do not occur in programs that follow all of the
programming rules for TNS languages, but compilers cannot catch misaligned
addresses that are computed at run time.
The behavior of TNS programs with misaligned addresses on TNS/E processors is
almost impossible to predict. If you are not sure that your program has only aligned
addresses, you can use the tracing facility to detect whether programs are using
misaligned pointers, and if so, where. You should then change the programs to avoid
misalignment.
In addition to the OCA, the data misalignment issue might affect the following HP
compilers. If you use these compilers, see the appropriate data alignment addenda:
Misalignment Tracing Facility
The misalignment tracing facility is enabled or disabled on a system-wide basis (that is,
for all processors in the node). By default, it is enabled (set to ON). It can be disabled
(set to OFF) only by the persons who configure the system, by means of the
Compiler T Number Addendum
TNS C T9255 C/C++ Programmer’s Guide Data Alignment Addendum
TNS C++ T9541
TNS c89 T8629
TNS COBOL85 T9257 COBOL85 Manual Data Alignment Addendum
TNS/R pTAL T9248 pTAL Reference Manual Data Alignment Addendum
TNS TAL T9250 TAL Programmer’s Guide Data Alignment Addendum