SPL to HP C/XL Migration Guide (30231-90001)
5-11
SOURCE is the word from which the bits will be extracted, DBIT is the
start bit in the destination word, SBIT is the start bit in the source
word, and LEN is the number of bits to be moved.
To use it, replace a CAT expression like
A CAT B (4:8:4)
with
BCONCAT(A,B,4,8,4)
Step 2: In the HP C/XL program, replace the SPL function procedure with
the HP C/XL function in Figure 5-5.
______________________________________________________________
| |
| unsigned short int BCONCAT( DEST , SOURCE , DBIT , SBIT , LEN ) |
| unsigned short int DEST , SOURCE , DBIT , SBIT , LEN ; |
| { |
| unsigned int TEMP ; |
| |
| LEN = 16 - LEN ; |
| TEMP = ( 0xFFFF >> LEN ) << ( LEN - DBIT ) ; |
| return( (unsigned short int) |
| ( ( DEST & ~TEMP ) | |
| ( ( DBIT < SBIT ? SOURCE << ( SBIT - DBIT ) |
| : SOURCE >> ( DBIT - SBIT ) ) & TEMP ) ) ) ;|
| } |
________________________________________________________________________________
Figure 5-5. HP C/XL BCONCAT Function: Bit Concatenation
The function may be executed with the same format as the SPL procedure,
e.g., "BCONCAT(A,B,4,8,4)", so further conversion is unnecessary.
Bit Shifts
Table 5-14. Bit Shift Operators
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
|
bit-shift-operation
: |
bit-shift-operation
: |
| | |
|
operand
&
shift-op
(
count
) | 1.
operand
<<
count
|
| | |
|
operand
: | 2.
operand
>>
count
|
| is an arithmetic or logical
primary
. | |
| | Form 1 shifts the bits of
operand
left |
|
shift-op
: |
count
positions. The sign bit is lost. |
| is one of 17 shift operators, described | Zero bits are inserted on the right. Same |
| below. | as SPL's LSL and DLSL. |
| The shift operator is used to determine | |
| the participation of the sign bit, | Form 2 shifts the bits of
operand
right |
| regardless of the type of the operand. |
count
positions. If
operand
is unsigned, |
| | zero bits are inserted on the left. If |
|
count
: |
operand
is signed, the sign bit is extended |
| is the number of bits to shift. | on the left. Almost (but not quite) the |
| | same as SPL's LSR, DLSR, ASR, and DASR. |
| | |