- /*
- * Now, due to sizeof(tmpspace), we are guaranteed large enough space.
- */
- buf = po->buffer;
- omsk = ~((1 << (8 - po->nboff)) - 1);
- off = (po->nboff += obits);
-
- /* Clear data of debris before meaningful bits */
- bits &= (((uint32_t)1 << obits) - 1);
-
- ASN_DEBUG("[PER out %d %u/%x (t=%d,o=%d) %x&%x=%x]", obits, bits, bits,
- po->nboff - obits, off, buf[0], omsk&0xff, buf[0] & omsk);
-
- if(off <= 8) /* Completely within 1 byte */
- bits <<= (8 - off),
- buf[0] = (buf[0] & omsk) | bits;
- else if(off <= 16)
- bits <<= (16 - off),
- buf[0] = (buf[0] & omsk) | (bits >> 8),
- buf[1] = bits;
- else if(off <= 24)
- bits <<= (24 - off),
- buf[0] = (buf[0] & omsk) | (bits >> 16),
- buf[1] = bits >> 8,
- buf[2] = bits;
- else if(off <= 31)
- bits <<= (32 - off),
- buf[0] = (buf[0] & omsk) | (bits >> 24),
- buf[1] = bits >> 16,
- buf[2] = bits >> 8,
- buf[3] = bits;
- else {
- ASN_DEBUG("->[PER out split %d]", obits);
- per_put_few_bits(po, bits >> 8, 24);
- per_put_few_bits(po, bits, obits - 24);
- ASN_DEBUG("<-[PER out split %d]", obits);
- }