blob: 2dad78b08b937c513079cc4b019d75a60ebe010f [file] [log] [blame]
Alexandre Lisiond204ea52013-10-15 10:16:25 -04001.\"
2.\" Copyright 1992 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.
5.\"
6.PU
7.TH BITTER 1
8.SH NAME
9bitter, sweet \(em code-generators for packing bits
10.SH SYNOPSIS
11bitter < input > output
12.br
13sweet < input > output
14.SH "DESCRIPTION"
15Bitter and sweet are two filters which turn a description of the
16form
17.nf
18 name number-of-bits
19 name number-of-bits
20 ...
21.nf
22into code.
23.PP
24Bitter generates code that packs the specified bits from their
25variables into an array of unsigned char referenced by an
26advancing pointer c.
27.PP
28Sweet generates code that unpacks the specified bits from an array
29of unsigned char referenced by a mutable pointer c into the
30named variables.
31.\" .SH OPTIONS
32.\" .SH "RETURN VALUE"
33.\" .SH ERRORS
34.SH EXAMPLES
35.nf
36% cat in
37amaretto 1
38banana 2
39cherry 3
40strawberry 4
41vanilla 15
42walnut 15
43
44% bitter < in
45 *c++ = ((amaretto & 0x1) << 7)
46 | ((banana & 0x3) << 5)
47 | ((cherry & 0x7) << 2)
48 | ((strawberry >> 2) & 0x3);
49 *c++ = ((strawberry & 0x3) << 6)
50 | ((vanilla >> 9) & 0x3F);
51 *c++ = ((vanilla >> 1) & 0xFF);
52 *c++ = ((vanilla & 0x1) << 7)
53 | ((walnut >> 8) & 0x7F);
54 *c++ = walnut & 0xFF;
55
56% sweet < in
57 amaretto = (*c >> 7) & 0x1;
58 banana = (*c >> 5) & 0x3;
59 cherry = (*c >> 2) & 0x7;
60 strawberry = (*c++ & 0x3) << 2;
61 strawberry |= (*c >> 6) & 0x3;
62 vanilla = (*c++ & 0x3F) << 9;
63 vanilla |= (*c++ & 0xFF) << 1;
64 vanilla |= (*c >> 7) & 0x1;
65 walnut = (*c++ & 0x7F) << 8;
66 walnut |= *c++;
67.SH NOTES
68This is a quick hack for the gsm_encode() and gsm_decode() routines.
69.SH BUGS
70Please direct bug reports to jutta@cs.tu-berlin.de and cabo@cs.tu-berlin.de.