2
* Copyright 1996 by Jutta Degener and Carsten Bormann, Technische
3
* Universitaet Berlin. See the accompanying file "COPYRIGHT" for
4
* details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
9
/* Generate code to pack a bit array from a name:#bits description */
16
/* This module is the opposite of sour. Sweet was already taken,
17
* that's why it's called ginger. (Add one point if that reminds
18
* you of Gary Larson.)
21
#define WORD_BITS 16 /* sizeof(uword) * CHAR_BIT on the
22
* target architecture---if this isn't 16,
23
* you're in trouble with this library anyway.
26
#define BYTE_BITS 8 /* CHAR_BIT on the target architecture---
27
* if this isn't 8, you're in *deep* trouble.
30
void write_code P2((s_spex, n_spex), struct spex * s_spex, int n_spex)
32
struct spex * sp = s_spex;
35
printf("uword sr = 0;\n");
37
for (; n_spex > 0; n_spex--, sp++) {
39
while (n_in < sp->varsize) {
40
if (n_in) printf("sr |= (uword)*c++ << %d;\n", n_in);
41
else printf("sr = *c++;\n");
45
printf("%s = sr & %#x; sr >>= %d;\n",
46
sp->var, ~(~0U << sp->varsize), sp->varsize);
52
fprintf(stderr, "%d bits left over\n", n_in);