C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

In C, you can use either:
Bit-wise operators & (and) and | (or)
Defines
This TAL bit-deposit operation and C bit-wise operation are equivalent:
TAL Code C Code
INT x := -1; short a = -1;
INT y := 0; short b = 0;
short temp = 0;
PROC example;
BEGIN void example ()
y.<0:2> := x.<10:12>; {
END; /* you can combine these */
/* with wider margins */
temp = a & 070;
temp = temp << 10;
b = (b & 017777)|temp;
}
Bit extractions and bit deposits are not portable to future software platforms.
UNSIGNED Variables and Packed Bit Fields
In general, TAL UNSIGNED simple variables in structures are compatible with C unsigned packed
bit fields (which appear only in structures). You cannot, however, pass C bit fields as reference
parameters to TAL routines.
This UNSIGNED variables and C unsigned bit fields are compatible:
TAL Code C Code
STRUCT stuffed (*); struct stuffed;
BEGIN {
INT x; int x;
UNSIGNED(1) a; unsigned a : 1;
UNSIGNED(5) b; unsigned b : 5;
UNSIGNED(3) c; unsigned c : 3;
UNSIGNED(4) d; unsigned d : 4;
UNSIGNED(9) e; unsigned e : 9;
UNSIGNED(2) f; unsigned f : 2;
END; };
STRUCT packed (stuffed); struct stuffed PACKED;
If the WIDE pragma is not specified, the TNS C compiler normally packs adjacent bit fields in a
16-bit word. If the WIDE pragma is specified, the TNS C compiler normally packs adjacent bit
fields in a 32-bit word.
TAL UNSIGNED(1–16) and C bit fields of like size are compatible. TAL UNSIGNED(17–31) and
C bit fields of like size are compatible.
The TAL compiler always packs adjacent UNSIGNED simple variables in 16-bit words:
It starts the first UNSIGNED variable on a word boundary.
It packs each successive UNSIGNED variable in the remaining bits of the same word as the
preceding UNSIGNED variable if:
The variable contains 1 to 16 bits and fits in the same word
The variable contains 17 to 31 bits and fits in the same word plus the next word
If an UNSIGNED variable does not fit in the same word or double word, the compiler starts
the variable on the next word boundary.
The operator you use determines whether UNSIGNED values are signed or unsigned:
114 Mixed-Language Programming for TNS Programs