HP 3000 Manuals

SPL BEXTRACT Procedure: Bit Extraction [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation


SPL to HP C/XL Migration Guide

SPL BEXTRACT Procedure:  Bit Extraction 

     <<  BEXTRACT          SPL BIT EXTRACTION                            >>
     <<                                                                  >>
     <<  This procedure emulates the SPL bit extraction, for example:    >>
     <<     x := y.(10:4);                                               >>
     <<  as an SPL procedure:                                            >>
     <<     x := BEXTRACT(y,10,4);                                       >>
     <<                                                                  >>
     <<  The parameters to BEXTRACT are:                                 >>
     <<     wd   --  Word (unsigned short) to extract bits from.         >>
     <<     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) word.                              >>

     LOGICAL PROCEDURE BEXTRACT(wd,sb,n);
       VALUE wd, sb, nb;
       LOGICAL wd;
       INTEGER sb, nb;
     BEGIN
       BEXTRACT := (wd & LSL(sb)) & LSR(16-nb);
     END;



MPE/iX 5.0 Documentation