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

5- 10
Bit Concatenation (Merging)
Table 5-13. Bit Concatenation
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
|
bit-concatenation-operation
: | No direct equivalent. |
| | |
|
dest
CAT
source
(
dbit
:
sbit
:
len
) | |
| | |
|
source
: | |
| is a 16-bit value from which bits are | |
| extracted. | |
| | |
|
dest
: | |
| is a 16-bit value in which bits are | |
| deposited. | |
| | |
|
dbit
,
sbit
,
len
: | |
| | |
| are values from 0 to 15. | |
| | |
---------------------------------------------------------------------------------------------
The SPL CAT operation is a means of constructing a new 16-bit quantity
from two existing 16-bit words. A bit field is extracted from
source
and deposited into a same-length field in
dest
. Thus:
A := %(16)ABCD;
B := %(16)1234;
X := A CAT B (4:8:4);
Bits 8 through 11 of word B are extracted and deposited in a copy of word
A, replacing bits 4 through 7. The resulting value equals %(16)A3CD. The
assignment places the value in X. A and B are unchanged.
Step 1: In the SPL program, convert the SPL operation to a function
procedure, such as BCONCAT shown in Figure 5-4 performs the same
operation.
_______________________________________________________
| |
| LOGICAL PROCEDURE BCONCAT( DEST , SOURCE , DBIT , SBIT , LEN ) ;|
| VALUE DEST , SOURCE , DBIT , SBIT , LEN ; |
| LOGICAL DEST , SOURCE ; |
| INTEGER DBIT , SBIT , LEN ; |
| BEGIN |
| LOGICAL M ; |
| LEN := 16 - LEN ; |
| M := ( %(16)FFFF & LSR( LEN ) ) & LSL( LEN - DBIT ) ; |
| BCONCAT := ( DEST LAND NOT( M ) ) LOR |
| ( IF DBIT < SBIT |
| THEN SOURCE & LSL( SBIT - DBIT ) |
| ELSE SOURCE & LSR( DBIT - SBIT ) LAND M ) ;|
| END ; |
_______________________________________________________________________
Figure 5-4. SPL BCONCAT Procedure: Bit Concatenation
In the procedure, DEST is the word where the bits will be deposited,