Object Code Accelerator Manual
Preparing Your Program for TNS/E Systems
Object Code Accelerator Manual—528144-003
2-10
Odd-Byte References
°
Contextual optimizations
°
How the instruction's result is used by later instructions
•
The SCF attribute TNSMISALIGN (see Misalignment Handling on page 2-15)
The varying behaviors and symptoms that misalignment errors cause can be
confusing, for the following reasons:
•
A source program can produce erroneous TNS object code that seems to execute
correctly until you change the source program in an apparently innocent way.
•
The program might behave differently in TNS mode than it does in accelerated
mode. (Neither mode is better at avoiding alignment problems.)
•
The debugger might display a different value for a variable than the program sees,
because the debugger never “rounds down” addresses.
•
The program might “round down” addresses for storage operations but not for
subsequent retrieval operations of the same misaligned operand (or the reverse).
TNS/E systems do not support the same odd-byte references to doublewords (4-byte
units) or quadruplewords (8-byte units) as TNS systems do. Odd-byte references are
made when the least significant bit (bit 31) of an extended pointer is set.
•
TNS systems ignore bit 31 of an extended pointer and fetch or store data starting
from the byte prior to the addressed one to ensure that the address is on a word
boundary. This behavior is probably not what you intended.
•
On TNS/E systems, odd-byte references to doublewords or quadruplewords are
unpredictable; programs might trap or they might continue executing. Extended
pointers to variables accessed as doublewords or quadruplewords must not have
their least significant bit set. If your program was written following good TAL
programming practices, odd-byte references are not a concern.
In TAL, data types stored as doublewords or quadruplewords include INT(32),
FIXED(n), REAL, REAL(64), and INT(64). In C, data types stored as doublewords or
quadruplewords include long, unsigned long, long long, float, and double.
You can use the Misalignment Tracing Facility to detect if your programs are using
misaligned pointers.This tool detects where in the program the misaligned pointers are
located so you can change the program to avoid misalignment. See Misalignment
Tracing Facility on page 2-13 for more information.
Odd-byte references to words (2-byte units) result in compatibility traps.
Detection Guidelines
•
Look for odd-byte references to doublewords or quadruplewords.
•
Look for uninitialized pointers. Many odd-byte references to doublewords and
quadruplewords result from uninitialized pointers (previously undetected
programming errors).