next up previous index
Next: M423 Increment a Up: CERNLIB Previous: M421 Package for

M422 Handling Packed Vectors of Bytes

Routine ID: M422
Author(s): J. Zoll, C. LetertreLibrary: KERNLIB
Submitter: Submitted: 28.01.1971
Language: Fortran or AssemblerRevised: 16.09.1991

PACBYT allows handling of packed vectors of bytes. Any such vector consists of a string of bytes, all of NBITS bits, INWORD of them packed into one computer word, stored from right to left.

Structure:

SUBROUTINE and FUNCTION subprograms
User Entry Names: PKBYT, UPKBYT, JBYTPK, SBYTPK
External References: JBYT, SBYT (M421) (Fortran version)

Usage:

The 2--word vector MPACK specifies the packing parameters:

    MPACK(1) = NBITS
    MPACK(2) = INWORD
MPACK(1)=0 is accepted as specifying both NBITS=1 and INWORD equal to the number of bits per word on the given computer.
    CALL PKBYT(IB,MX,JX,N,MPACK)
packs the N--word vector IB of small integers into the bytes JX,JX+1,...,JX+N-1 of the byte-vector MX.
    CALL UPKBYT(MA,JA,IY,N,MPACK)
unpacks the N bytes JA,JA+1,...,JA+N-1 of the packed byte-vector MA into the vector IY of small integers.
    IX = JBYTPK(MA,JA,MPACK)
fetches the JA-th byte from the packed byte-vector MA.
    CALL SBYTPK(IT,MX,JX,MPACK)
sets the first byte from IT into the JX'th byte of the packed byte vector MX.

Notes:

  1. These routines, and the manner of packing byte-vectors, is compatible with the routines JBYT and SBYT (M421), except that there the location of a byte in the word is specified, whereas here the ordinal number of a byte in the vector has to be given. The conversion is as follows:

    The byte with ordinal number J is found in word JW=(J-1)/INWORD+1 ,
    on byte JB=J-(JW-1)*INWORD

    starting at bit L=(JB-1)*NBITS+1 .

  2. Bits and bytes are numbered from right to left within one and the same computer word; across a word boundary there is a jump from the most significant part of the current word to the least significant part of the next word.

M423



next up previous index
Next: M423 Increment a Up: CERNLIB Previous: M421 Package for


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