C
C SUBROUTINE 'STBITS'
C ===================
C
C Set a bit field within a word to a given (unsigned) integer value
C
C **** THIS ROUTINE CONTAINS MACHINE DEPENDENT CODE ****
C
      SUBROUTINE STBITS (IWORD,LSB,NBITS,IVAL)
C
C PARAMETERS
C
C      IWORD (I/O)  The word in which the bits are to be set
C        LSB (I)    The least significant bit offset for the bit field
C      NBITS (I)    The number of bits in the bit field (must be less than
C                   the word length)
C       IVAL (I)    The unsigned integer value to be set in the bit
C                   field (The user should ensure that this value will
C                   fit within the requested bit field)
C
C ***Convex/Vax version***
C
C====== Set the bits
C
      KMSK = 2**NBITS - 1
      KVAL = IVAL
      KMSK = ISHFT(KMSK,LSB)
      KMSK = NOT(KMSK)
      KVAL = ISHFT(KVAL,LSB)
      IWORD = IOR(IAND(IWORD,KMSK),KVAL)
      RETURN
      END
C
C FUNCTION 'NBITST'
C =================
C
C Return the (unsigned) integer value held within a bit field in a word
C
C *** THIS ROUTINE CONTAINS MACHINE DEPENDENT CODE ***
C
      FUNCTION NBITST(IWORD,LSB,NBITS)
C
C PARAMETERS
C
C      IWORD (I)    The word containing the bits to be examined
C        LSB (I)    The least significant bit offset for the bit field
C      NBITS (I)    The number of bits in the bit field (Must be less
C                   than the word length)
C
C ***Convex/Vax version***
C
C====== Get the bit value
C
      KMSK = 2**NBITS - 1
      NBITST = IAND(ISHFT(IWORD,-LSB),KMSK)
      RETURN
      END
