pTAL Reference Manual (H06.08+)

Expressions
HP pTAL Reference Manual523746-006
5-33
Bit Shifts
Bit Shifts
A bit shift operation shifts a bit field a specified number of positions to the left or to the
right within a variable without altering the variable. RISC and Itanium architectures do
not include a signed left-shift operation, so pTAL compiles a signed left shift (for
example, i << 8) as an unsigned left shift (i '<<' 8).
int-expression
is an INT arithmetic expression. int-expression can contain STRING, INT, or
UNSIGNED(1-16) operands. The bit shift occurs within a word.
dbl-expression
is an INT(32) arithmetic expression. dbl-expression can contain INT(32) or
UNSIGNED(17-31) operands. The bit shift occurs within a doubleword.
shift-operator
is one of the operators described in Table 5-1 on page 5-3.
positions
is an INT expression that specifies the number of bit positions to shift the bit field.
A value greater than 31 gives undefined results.
The shift count must be less than the number of bits in the shifted value; therefore, you
can shift an INT value up to 15 bits left or right, and an INT(32) value up to 31 bits left
or right.
The compiler reports an error if the shift count is a constant and its value is greater
than the number of bits in the value to shift.
If the shift amount is a dynamic expression and is greater than the maximum allowed
(one bit less than the number of bits being shifted), the result depends on the
CHECKSHIFTCOUNT compiler directive, as follows:
If CHECKSHIFTCOUNT is enabled and a dynamic shift count is equal to or greater
than the number of bits in the value being shifted, the system aborts your program
with an instruction trap.
If CHECKSHIFTCOUNT is disabled (you specify NOCHECKSHIFTCOUNT), and a
dynamic shift count is equal to or greater than the number of bits in the value being
shifted, program operation is undefined.
int-expression
dbl-expression
shift-operator positions
VST017.vsd