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

5-31
Then separate the bit deposit from any multiple assignments and convert
it to a procedure call. For example,
I.(5:6) := J + K ;
would become
BDEPOSIT(@I,5,6,J+K);
Note that the address of the first parameter is formed with the "@"
operator, and that the parameter has been declared type LOGICAL (16 bit
word), and passed by value. Within BDEPOSIT, this value is assigned to a
pointer to allow the actual value to be accessed. This rather
unconventional approach (normal SPL practice would be to pass this
parameter by reference), is to simplify later conversion to the HP C/XL
function described below.
Step 2: In HP C/XL, replace the SPL procedure with the HP C/XL BDEPOSIT
function shown in Figure 5-20.
___________________________________________
| |
| void BDEPOSIT(dw,sb,nb,exp) |
| unsigned short *dw, sb, nb, exp; |
| { |
| unsigned short m; |
| nb = 16-nb; |
| sb = nb-sb; |
| m = (0xFFFF>>nb)<<sb; |
| *dw = (*dw & ~m) | (exp<<sb & m);|
| } |
___________________________________________
Figure 5-20. HP C/XL BDEPOSIT Function: Bit Assignment
Then replace the converted SPL call to BDEPOSIT:
BDEPOSIT(@I,5,6,J+K);
with:
BDEPOSIT(&I,5,6,J+K);
Note that the only difference in the calls is that "@" is changed to "&".