bitter.1 1.7 KB

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