pTAL Reference Manual (H06.08+)

Built-In Routines
HP pTAL Reference Manual523746-006
15-28
$BITLENGTH
$BITLENGTH
$BITLENGTH returns an INT value that is the length, in bits, of a variable.
variable
is the identifier of a simple variable, array element, pointer, structure, or structure
data item.
$BITLENGTH returns the length, in bits, of a single occurrence of a simple variable,
array element, structure, structure item, or item to which a pointer points.
The length of a structure or substructure occurrence is the sum of the lengths of all
items contained in the structure or substructure. Complete the structure before you use
$BITLENGTH to obtain the length of any of the items in the structure.
To compute the total number of bits in an entire array or substructure, multiply the
value returned by $BITLENGTH by the value returned by $OCCURS. To compute the
total number of bits in a structure, first round up the value returned by $BITLENGTH to
the word boundary and then multiply the rounded value by the value returned by
$OCCURS.
You can use $BITLENGTH in LITERAL
expressions and global initializations, because
it always returns a constant value.
pTAL privileged procedure No
Can be executed only by privileged procedures No
Sets condition code No
Sets $CARRY No
Sets $OVERFLOW No
Example 15-15. $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
variable
( )
VST074.vsd
$BITLENGTH