SPL to HP C/XL Migration Guide (30231-90001)

5- 12
---------------------------------------------------------------------------------------------
| | |
| Example: | Example: |
| | |
|
operand
is LOGICAL or INTEGER: |
operand
is unsigned short int or short int:|
| | |
| X := Y & LSL(4) ; | |
| | X = Y << 4 ; |
| | |
---------------------------------------------------------------------------------------------
Please notice that the examples above demonstrate the only simple exact
equivalents between SPL and HP C/XL.
Unlike SPL, the HP C/XL shift operators take note of the data type being
shifted, and behave differently for signed and unsigned data. To pro-
vide operations similar to the SPL shift operators, some manipulation
and type casting are necessary. There are no circular shifts in HP C/
XL, and these must be emulated by iteration.
The best solution is to convert the operations to function calls and
#define macro references, in the form:
spl-shift-op
(
operand
,
count
)
For example, the SPL expression:
Y & LSL(4)
would become the HP C/XL expression:
LSL(Y,4)
Suggested macro directives and functions are described in the following
sections.
NOTE If necessary, check the source code and ensure that the value of C
(
count
) is not negative in these macros and functions. You may
wish to use the HP C/XL abs (absolute value) function.
16-Bit Shift Operators.
The six SPL 16-bit (single-word) shift operators are described in Table
5-15.