TAL Reference Manual
Standard Functions
TAL Reference Manual—526371-001
14-9
Example of $BITLENGTH Function
Example of $BITLENGTH Function
In this example, $BITLENGTH returns the length, in bits, of one occurrence of structure
S:
INT s_len; !Declare variable
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 Function
The $BITOFFSET function returns the number of bits from the address of the zeroth
structure occurrence to a structure data item.
variable
is the fully qualified identifier of a structure data item.
Usage Considerations
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.
$BITOFFSET (
variable )
VST1404.vsd