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

5- 30
| specify a bit field in itself where the | This operation may be performed separately |
| value will be deposited. | with the user-defined function BDEPOSIT, |
| | described below. |
| | |
---------------------------------------------------------------------------------------------
| | |
| May be used as an expression. | Same as SPL. |
| Its value is the value stored into the | |
| leftmost operand. Its type is the type of | |
| the leftmost operand. | |
| | |
---------------------------------------------------------------------------------------------
For compatability with very old systems, SPL accepts the "_" (under-
score) character as an alternate to the ":=" assignment symbol. (Early
terminals and printers labeled and displayed what now is the underscore
as a "left arrow" symbol, "<--".)
SPL Examples:
Z := B * F;
arithmetic expression assignment
F1 := F2 = F3;
logical expression assignment
Z.(5:6) := P := B;
multiple assignment, bit deposit
Z := (B := B + 1) * 2;
assignment in expression
Z _ B;
underscore replacing ":="
HP C/XL Examples:
i = k * l; /*arithmetic expression assignment*/
l1 = l2 == l3; /*logical expression assignment*/
i = (k = k + 1) * 2; /*assignment in expression*/
i = (++k) * 2; /*same operation*/
The SPL bit deposit operation may be emulated in SPL and converted to HP
C/XL in two steps.
Step 1: In SPL, add the BDEPOSIT procedure in Figure 5-19 to the
compilation unit.
_________________________________________________________
| |
| PROCEDURE BDEPOSIT(dw,sb,nb,expr); |
| VALUE dw, sb, nb, expr; |
| LOGICAL dw, sb, nb, expr; |
| BEGIN |
| LOGICAL M; |
| POINTER P; |
| nb := 16-nb; |
| sb := nb-sb; |
| M := (%(16)FFFF & LSR(nb)) & LSL(sb); |
| @p := dw; |
| p := (p LAND NOT m) LOR (expr & LSL(sb) LAND m);|
| END; |
_________________________________________________________
Figure 5-19. SPL BDEPOSIT Procedure: Bit Assignment
Here dw is the address of the destination word, sb is the starting bit of
the deposit field, nb is the number of bits to be deposited, and expr is
the value to be deposited into the field.