HP C/XL BEXTRACT Macro and Function: Bit Extraction [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation
SPL to HP C/XL Migration Guide
HP C/XL BEXTRACT Macro and Function: Bit Extraction
/*************************************************************
BEXTRACT SPL Bit Extraction
This macro and function perform the SPL bit extraction:
x := y.(10:4);
which may be replaced in HP C by:
x = BEXTRACT(y,10,4);
The parameters to BEXTRACT are:
wd -- The word (unsigned short int) from which to extract bits.
sb -- Starting bit of field (0 through 15, left to right).
nb -- Number of bits in field.
The return value will be the extracted field, right
justified in a 16 bit (unsigned short int) word.
**************************************************************/
#define BEXTRACT(w,s,n) (((unsigned short int)((w)<<(s)))>>(16-(n)))
/*************************************************************/
unsigned short int BEXTRACT(sw,sb,nb)
unsigned short int sw, sb, nb;
{
return((unsigned short int)((sw<<sb))>>(16-nb));
}
MPE/iX 5.0 Documentation