TAL Programmer's Guide Data Alignment Addendum
Table Of Contents

TAL Misalignment Examples
TAL Programmer's Guide Data Alignment Addendum—524967-003
4-4
Invalid Conversion of Odd-Byte String Addresses
10. Using 16-bit addressing and ignoring the representational difference between byte
pointers and word pointers
The following declaration applies only to some byte-aligned substructures:
STRING .node (node^template);
The preceding declaration is not pointer-compatible with the following declaration,
which applies to all structures and to most substructures:
INT .node (node^template);
A programming error does not cause misaligned addresses, but it produces an
address that is twice or half the intended value.
11. Using 32-bit addressing and ignoring the difference between extended pointers for
strings and extended pointers for nonstrings
The following declarations using extended pointers are semantically equivalent:
STRING .EXT node (node^template);
INT .EXT node (node^template);
Many existing programs use the syntax STRING .EXT even when the target
structure contains nonstring fields that require aligned addresses. This coding style
is not worth changing now, but remember that even-byte aligned addresses are
required, despite the keyword STRING.
Example 4-2. TAL Assignment of String Pointer to int Pointer
(Item 1, Item 5)
Change this:
! extract 16-bit length from beginning of long string:
string .ext name;
int .ext words;
@words := @name; ! legal only when name has even-byte address
lth := words; ! misalignment traps here
@name := @name[2];
To this:
! extract 16-bit length from beginning of long string:
string .ext name;
int .ext words;
lth := (name[0] '<<' 8) lor name[1];
@name := @name[2];