SPL to HP C/XL Migration Guide (30231-90001)
5- 14
Figure 5-10. HP C/XL CSL Function: Bit Shift Operation
__________________________________________________________________________
| |
| unsigned short int CSR(X,C) |
| unsigned short int X; |
| int C; |
| { |
| for (;;--C) /*infinite loop, decrementing C after each iteration*/|
| { |
| if (C == 0) return(X); /*exit, returning X*/ |
| X = ((X & 0x0001) << 15) | X >> 1; |
| } |
| } |
__________________________________________________________________________
Figure 5-11. HP C/XL CSR Function: Bit Shift Operation
32-Bit Shift Operators.
The six SPL 32-bit (double-word) shift operators are described in Table
5-16.
Table 5-16. SPL 32-Bit Shift Operators
-------------------------------------------------------------------------------------------
| |
| shift-op Operation |
| |
-------------------------------------------------------------------------------------------
| |
| DLSL logical shift left (sign not retained) |
| |
| DLSR logical shift right (no sign extension) |
| |
| DASL arithmetic shift left (sign retained) |
| |
| DASR arithmetic shift right (sign extended) |
| |
| DCSL circular shift left (rotate 32 bits left) |
| |
| DCSR circular shift right (rotate 32 bits right) |
| |
-------------------------------------------------------------------------------------------
These operations may be performed in HP C/XL by the following #define
macro directives and functions. X represents the
operand
; C represents
the
count
.
___________________________________________________________________
| |
| #define DLSL(X,C) ((unsigned int)((unsigned int)(X) << (C)))|
___________________________________________________________________
Figure 5-12. HP C/XL DLSL Directive: Bit Shift Operation
___________________________________________________________________
| |
| #define DLSR(X,C) ((unsigned int)((unsigned int)(X) >> (C)))|
___________________________________________________________________