P-Code Instructions (pcode.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CvtWuQ<n>
                                              Up Contents Index Back
──P-Code Instructions───────────────────────────────────────────────────────
 
  Syntax
 
  CvtWuQ<n>
 
  /* Convert word to unsigned bit field. */
 
  Possible Instructions
 
  CvtWuQb
 
  Description
 
  Used to extract an unsigned bit field from the top word of the stack.
  The top word is popped, shifted, and masked, and the resulting value is
  pushed as a word back onto the stack. The one-byte parameter <n>
  specifies the shift count (0-15) and the width (minus 1) of the bit
  field (0-15).
 
  See also: CvtWQb
 
  Pseudocode equivalent:
 
  unsigned int w, width, shift
  width = (<n> >> 4) + 1;
  shift = <n> & 0xf;
  w = PopW();
  w >>= shift;
  w &= (2 ** width) - 1;
  PushW(w);
 
  Assigning a variable to the value of a structure's bit field will
  generate this instruction, as in
 
  typedef struct
  {
  unsigned uT1:2;
  unsigned uT2:4;
  unsigned uT3:8;
  } BF;
  BF *pbf;
 
  pbf->uT1 = 55;
  pbf->uT2 = pbf->uT1;     /* generate CvtWuQ<b> */
 
 
                                     -♦-