next up previous index
Next: M442 Fortran Emulation Up: CERNLIB Previous: M439 Set or

M441 Handling Bits and Bytes, Bit Zero the Least Significant

Routine ID: M441
Author(s): M. MetcalfLibrary: KERNLIB or Fortran library
Submitter: Submitted: 10.12.1984
Language: Fortran with ISA extensionsRevised: 18.10.1985

BITPAK handles bits and bytes in a single word, with bit zero being the least significant bit.

Structure:

SUBROUTINE and FUNCTION subprograms
User Entry Names:
IOR, IAND, NOT, IEOR, ISHFT, ISHFTC, IBITS, MVBITS,
BTEST, IBSET, IBCLR

Usage:

A numeric storage unit is considered to consist of a string of bits numbered from right to left, starting at zero. The standard MIL-STD-l753 defines ll bit manipulation functions on such units, 8 of which are the ANSI/ISA functions found as intrinsic functions in many compilers. This package complements the functions available in compilers, ensuring that the full range is available on all machines. This description includes all the functions for the sake of completeness.
Logical operations:
IOR(M,N)provides the inclusive ORof the two integerarguments.
IAND(M,N)provides the logical ANDof the two integerarguments.
NOT(M)provides the logical complement of the integerargument.
IEOR(M,N)provides the exclusive ORof the two integerarguments.

Shift operations:

ISHFT(M,K)provides the value of the integer argument Mwith the bitsshifted. Bits shifted out to the left or right are lost, and zeros areshifted in from the opposite end.
ISHFTC(M,K,IC)provides the value of the integer argument Mwith the rightmostICbits shifted, and the remaining bits untouched. The shift iscircular; no bits are lost.

Bit subfields:
IBITS(M,I,LEN)provides, right justified, the value of the LENbits of theinteger argument M, starting from position I.
CALL MVBITS(M,I,LEN,N,J)moves LENbits of integer argument M, starting at positionI, to the integer argument N, starting at position J.All other bits of Nare left untouched. The arguments Mand Nmay refer to the same numeric storage unit.

Bit testing:
BTEST(N,I)has the value .TRUE.if bit Iof theinteger argument Nis set, and .FALSE.otherwise.Note that many compilers require BTESTto be declared typeLOGICAL.
IBSET(N,I)has the value of the integer argument Nwith bit Iset to 1.
IBCLR(N,I)has the value of the integer argument Nwithbit Iset to 0.

Notes:

If bits are specified outside the range of one numeric storage unit, or if fields are specified which are longer than one numeric storage unit or zero, or if shifts are specified which are longer than the fields being shifted, then the results are undefined.

M442



next up previous index
Next: M442 Fortran Emulation Up: CERNLIB Previous: M439 Set or


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995