TAL Programmer's Guide Data Alignment Addendum

TAL Programmer's Guide Data Alignment Addendum524967-003
1-1
1 Introduction
Programs compiled with the TNS instruction set must follow the even-byte data
alignment rules of TNS compilers. Certain violations of these programming rules might
lead to run-time errors. This addendum describes these violations and explains how to
avoid them and how to diagnose them at run time.
TNS systems treat all nonbyte data as one or more 16-bit words. The TNS instruction
set includes data access instructions that use 32-bit byte addresses (which must be
even addresses for correct operation). 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/R and 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. Compilers cannot catch misaligned addresses
that are computed at run time.
The behavior of TNS programs with misaligned addresses on TNS/R and 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 program to
avoid misalignments.
In addition to TAL, the data misalignment issue might affect programs that use the
following HP products. If you use these products, see the appropriate documents:
Product T Number Document
Accelerator T9276 Accelerator Manual Data Alignment Addendum
TNS C T9255 C/C++ Programmers Guide
TNS C++ T9541
TNS c89 T8629
TNS COBOL85 T9257 COBOL Manual for TNS and TNS/R Programs
TNS/R pTAL T9248 pTAL Reference Manual