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

B-1
Appendix B HP C/XL Funtions to Emulate SPL Operations
The HP C/XL macro directives and function definitions in this appendix
emulate SPL operations that are performed by special features of the SPL
language, usually designed to access specific instructions available
under the MPE V operating system. If an SPL program has had these
operations replaced by the SPL procedures in Appendix A, simple
replacement of those procedure declarations by these HP C/XL macros and
functions are all that will be necessary to perform the same operation in
HP C/XL. Note that variable names are compatible with respect to case and
special characters.
The HP C/XL macro directives and function definitions in this appendix
emulate SPL operations that are performed by special features of the SPL
language, usually designed to access specific instructions available
under the MPE V operating system. If an SPL program has had these
operations replaced by the SPL procedures in Appendix A, simple
replacement of those procedure declarations by these HP C/XL macros and
functions are all that will be necessary to perform the same operation in
HP C/XL. Note that variable names are compatible with respect to case and
special characters.
HP C/XL BCONCAT Function: Bit Concatenation
/***************************************************************
BCONCAT SPL BIT CONCATENATION
This emulates the SPL bit concatenation operation, for example:
X := A CAT B (4:8:4);
Using this function, this may be converted to HP C with:
x = BCONCAT(a,b,4,8,4);
The parameters used by BCONCAT are:
a -- 1st 16 bit word to be merged into.
b -- 2nd 16 bit word with field to be merged.
sa-- Starting bit in word "a".
sb-- Starting bit in word "b".
n -- Number of bits to merge.
The 16 bit value returned by the function is the result of
the concatenate operation.
***************************************************************/
unsigned short int BCONCAT(a,b,sa,sb,n)
unsigned short int a, b, sa, sb, n;
{
unsigned int m;
n = 16-n;
m = (0xFFF>>n)<<(n-sa);
return((unsigned short int)((a & ~m) |
((sa<sb ? b<<(sb-sa) : b>>(sa-sb)) & m)));
}