HP 3000 Manuals

HP C/XL BCONCAT Function: Bit Concatenation [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation


SPL to HP C/XL Migration Guide

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)));
     }



MPE/iX 5.0 Documentation