1 | #! /bin/sh
|
---|
2 |
|
---|
3 |
|
---|
4 | # get bits of $1
|
---|
5 |
|
---|
6 | # make sure it fits in 16 bit
|
---|
7 | ORIG=`expr $1 \% 65536`
|
---|
8 |
|
---|
9 | # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
---|
10 | # 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768
|
---|
11 |
|
---|
12 | N=0
|
---|
13 |
|
---|
14 | N=`expr $ORIG \/ 32768`
|
---|
15 | N_16=$N
|
---|
16 | if test "x$N" = "x1"; then
|
---|
17 | echo "#define $2_16 1"
|
---|
18 | fi
|
---|
19 | ORIG=`expr $ORIG \- $N_16 \* 32768`
|
---|
20 |
|
---|
21 | N=`expr $ORIG / 16384`
|
---|
22 | N_15=$N
|
---|
23 | if test "x$N" = "x1"; then
|
---|
24 | echo "#define $2_15 1"
|
---|
25 | fi
|
---|
26 | ORIG=`expr $ORIG \- $N_15 \* 16384`
|
---|
27 |
|
---|
28 | N=`expr $ORIG \/ 8192`
|
---|
29 | N_14=$N
|
---|
30 | if test "x$N" = "x1"; then
|
---|
31 | echo "#define $2_14 1"
|
---|
32 | fi
|
---|
33 | ORIG=`expr $ORIG \- $N_14 \* 8192`
|
---|
34 |
|
---|
35 | N=`expr $ORIG \/ 4096`
|
---|
36 | N_13=$N
|
---|
37 | if test "x$N" = "x1"; then
|
---|
38 | echo "#define $2_13 1"
|
---|
39 | fi
|
---|
40 | ORIG=`expr $ORIG \- $N_13 \* 4096`
|
---|
41 |
|
---|
42 | N=`expr $ORIG \/ 2048`
|
---|
43 | N_12=$N
|
---|
44 | if test "x$N" = "x1"; then
|
---|
45 | echo "#define $2_12 1"
|
---|
46 | fi
|
---|
47 | ORIG=`expr $ORIG \- $N_12 \* 2048`
|
---|
48 |
|
---|
49 | N=`expr $ORIG \/ 1024`
|
---|
50 | N_11=$N
|
---|
51 | if test "x$N" = "x1"; then
|
---|
52 | echo "#define $2_11 1"
|
---|
53 | fi
|
---|
54 | ORIG=`expr $ORIG \- $N_11 \* 1024`
|
---|
55 |
|
---|
56 | N=`expr $ORIG \/ 512`
|
---|
57 | N_10=$N
|
---|
58 | if test "x$N" = "x1"; then
|
---|
59 | echo "#define $2_10 1"
|
---|
60 | fi
|
---|
61 | ORIG=`expr $ORIG \- $N_10 \* 512`
|
---|
62 |
|
---|
63 | N=`expr $ORIG \/ 256`
|
---|
64 | N_09=$N
|
---|
65 | if test "x$N" = "x1"; then
|
---|
66 | echo "#define $2_09 1"
|
---|
67 | fi
|
---|
68 | ORIG=`expr $ORIG \- $N_09 \* 256`
|
---|
69 |
|
---|
70 | N=`expr $ORIG \/ 128`
|
---|
71 | N_08=$N
|
---|
72 | if test "x$N" = "x1"; then
|
---|
73 | echo "#define $2_08 1"
|
---|
74 | fi
|
---|
75 | ORIG=`expr $ORIG \- $N_08 \* 128`
|
---|
76 |
|
---|
77 | N=`expr $ORIG \/ 64`
|
---|
78 | N_07=$N
|
---|
79 | if test "x$N" = "x1"; then
|
---|
80 | echo "#define $2_07 1"
|
---|
81 | fi
|
---|
82 | ORIG=`expr $ORIG \- $N_07 \* 64`
|
---|
83 |
|
---|
84 | N=`expr $ORIG \/ 32`
|
---|
85 | N_06=$N
|
---|
86 | if test "x$N" = "x1"; then
|
---|
87 | echo "#define $2_06 1"
|
---|
88 | fi
|
---|
89 | ORIG=`expr $ORIG \- $N_06 \* 32`
|
---|
90 |
|
---|
91 | N=`expr $ORIG \/ 16`
|
---|
92 | N_05=$N
|
---|
93 | if test "x$N" = "x1"; then
|
---|
94 | echo "#define $2_05 1"
|
---|
95 | fi
|
---|
96 | ORIG=`expr $ORIG \- $N_05 \* 16`
|
---|
97 |
|
---|
98 | N=`expr $ORIG \/ 8`
|
---|
99 | N_04=$N
|
---|
100 | if test "x$N" = "x1"; then
|
---|
101 | echo "#define $2_04 1"
|
---|
102 | fi
|
---|
103 | ORIG=`expr $ORIG \- $N_04 \* 8`
|
---|
104 |
|
---|
105 | N=`expr $ORIG \/ 4`
|
---|
106 | N_03=$N
|
---|
107 | if test "x$N" = "x1"; then
|
---|
108 | echo "#define $2_03 1"
|
---|
109 | fi
|
---|
110 | ORIG=`expr $ORIG \- $N_03 \* 4`
|
---|
111 |
|
---|
112 | N=`expr $ORIG \/ 2`
|
---|
113 | N_02=$N
|
---|
114 | if test "x$N" = "x1"; then
|
---|
115 | echo "#define $2_02 1"
|
---|
116 | fi
|
---|
117 | ORIG=`expr $ORIG \- $N_02 \* 2`
|
---|
118 |
|
---|
119 | N=`expr $ORIG \/ 1`
|
---|
120 | N_01=$N
|
---|
121 | if test "x$N" = "x1"; then
|
---|
122 | echo "#define $2_01 1"
|
---|
123 | fi
|
---|
124 | ORIG=`expr $ORIG \- $N_01 \* 1`
|
---|
125 |
|
---|
126 | #
|
---|
127 | # obsolete
|
---|
128 | #
|
---|
129 | # echo ${N_01} ${N_02} ${N_03} ${N_04} ${N_05} ${N_06} ${N_07} ${N_08} ${N_09} ${N_10} ${N_11} ${N_12} ${N_13} ${N_14} ${N_15} ${N_16}
|
---|
130 |
|
---|
131 | exit 0
|
---|
132 |
|
---|
133 |
|
---|