pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

Example 237 $BITLENGTH Routine
INT s_len;
STRUCT .s[0:3]; ! Declare four occurrences of a
BEGIN ! structure
UNSIGNED(1) flags[0:15];
UNSIGNED(2) status;
BIT_FILLER 14;
END;
s_len := $BITLENGTH (s); ! Return 32, the number of bits
! in one structure occurrence
$BITOFFSET
$BITOFFSET returns an INT value that is the offset, in bits, of a structure data item from the address
of the zeroth structure occurrence.
NopTAL privileged procedure
NoCan be executed only by privileged procedures
NoSets condition code
NoSets $CARRY
NoSets $OVERFLOW
variable
is the fully qualified identifier of a structure item.
The zeroth structure occurrence has an offset of 0. For items other than substructure, simple variable,
array, or pointer declared within a structure, $BITOFFSET returns a 0.
When you qualify the identifier of variable, you can use constant indexes but not variable
indexes; for example:
$BITOFFSET (struct1.subst[1].item) !1 is a constant index
To find the offset of an item in a structure, complete the structure before you use $BITOFFSET.
You can use $BITOFFSET in LITERAL expressions and global initializations, because it always
returns a constant value.
296 Built-In Routines