source: buchla-68k/lib700/mangle.c@ b8080f6

Last change on this file since b8080f6 was 73dd55f, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Prepare for automatic substitution.

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[f40a309]1/*
2 =============================================================================
3 mangle.c -- mangle a bit stream
4 Version 2 -- 1987-08-28 -- D.N. Lynx Crowe
5 (c) Copyright 1987 - D.N. Lynx Crowe
6 =============================================================================
7*/
8
9/*
10 =============================================================================
11 mangle(bitmap, nb, ib) -- reorder the 'nb' least significant bits
12 in 'ib' according to 'bitmap'. Assumes that 'bitmap' is at least 'nb'
13 words long, and that nb <= 32. The 'bitmap' translation table contains
14 an output word for each bit in the input word, with each 'bitmap' entry
15 corresponding to the bit number matching its index. For example,
16 'bitmap[0]' contains the word which will be 'OR'ed into the output if
17 the least significant bit of the input word is set, while 'bitmap[31]'
18 corresponds to the most significant bit of the input word.
19 =============================================================================
20*/
21
22long
23mangle(bitmap, nb, ib)
[73dd55f]24register long *bitmap;
25register short nb;
26register long ib;
[f40a309]27{
28 register long bm; /* scan mask */
29 register long rv; /* result value */
30 register short bn; /* bit number (bitmap index) */
31
32 bm = 0x00000001L; /* setup scan mask */
33 rv = 0x00000000L; /* clear the output word */
34
35 for (bn = 0; bn < nb; bn++) { /* scan across nb bits */
36
37 if (ib & bm) /* if the input bit is 1 */
38 rv |= bitmap[bn]; /* 'OR' the bitmap into rv */
39
40 bm <<= 1; /* shift the scan mask left */
41 }
42
43 return(rv); /* return rv as the result */
44}
Note: See TracBrowser for help on using the repository browser.