[ 簡単な説明 ]
磁気ディスク装置で使用されている変調コードの1種である、8−9GCRコードの変換表を作成します。 |
/* encode89.c */ #include <stdio.h> int main(void) { int i, j, k, m, m1, m2, n1, n2, r1, r2, s1, s2; int x1, x2, x3, x4, x5, x6, x7, x8; int y1, y2, y3, y4, y5, y6, y7, y8, y9; static char header[30] = "code input output"; printf(" %s %s %s %s\n", header, header, header, header); for(k = 0; k < 64; k++) { for(i = k; i < 256; i += 64) { printf(" %3d ", i); printf("%1d", x1 = (i >> 7) & 1); printf("%1d", x2 = (i >> 6) & 1); printf("%1d", x3 = (i >> 5) & 1); printf("%1d", x4 = (i >> 4) & 1); printf("%1d", x5 = (i >> 3) & 1); printf("%1d", x6 = (i >> 2) & 1); printf("%1d", x7 = (i >> 1) & 1); printf("%1d", x8 = i & 1); m = ((x1 | x2 | x3) & (x4 | x5) & (x6 | x7 | x8)) | (x2 & x7); m1 = m | ((x1 | x3) & x4); m2 = m | ((x8 | x6) & x5); n1 = !m & ((x1 | x3) & !x4); n2 = !m & ((x8 | x6) & !x5); r1 = !m & (!(x1 | x3) & x2); r2 = !m & (!(x8 | x6) & x7); s1 = !(x1 | x2 | x3); s2 = !(x8 | x7 | x6); y1 = x1 | r1 | (s1 & x4); y2 = (m1 & x2) | r1 | s1; y3 = x3 | r1 | (s1 & !x4); y4 = (m1 & x4) | (n1 & !x2) | (r1 & !x4) | (s1 & (!x5 | s2)); y5 = m & !(x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8); y6 = (m2 & x5) | (n2 & !x7) | (r2 & !x5) | (s2 & (!x4 | s1)); y7 = x6 | r2 | (s2 & !x5); y8 = (m2 & x7) | r2 | s2; y9 = x8 | r2 | (s2 & x5); printf(" %1d%1d%1d%1d%1d%1d%1d%1d%1d", y1, y2, y3, y4, y5, y6, y7, y8, y9); } putchar('\n'); } return 1; } |
code input output code input output code input output code input output 0 00000000 011101110 64 01000000 111101110 128 10000000 100101110 192 11000000 100001110 1 00000001 011101001 65 01000001 111101001 129 10000001 100101001 193 11000001 100001001 2 00000010 011101111 66 01000010 010010010 130 10000010 100101111 194 11000010 110010010 3 00000011 011100001 67 01000011 010010011 131 10000011 100100001 195 11000011 110010011 4 00000100 011101100 68 01000100 111101100 132 10000100 100101100 196 11000100 100001100 5 00000101 011101101 69 01000101 111101101 133 10000101 100101101 197 11000101 100001101 6 00000110 011100100 70 01000110 010010110 134 10000110 100100100 198 11000110 110010110 7 00000111 011100101 71 01000111 010010111 135 10000111 100100101 199 11000111 110010111 8 00001000 011101011 72 01001000 111101011 136 10001000 100101011 200 11001000 100001011 9 00001001 011001001 73 01001001 010011001 137 10001001 100011001 201 11001001 110011001 10 00001010 011000111 74 01001010 010011010 138 10001010 100011010 202 11001010 110011010 11 00001011 011001011 75 01001011 010011011 139 10001011 100011011 203 11001011 110011011 12 00001100 011001100 76 01001100 010011100 140 10001100 100011100 204 11001100 110011100 13 00001101 011001101 77 01001101 010011101 141 10001101 100011101 205 11001101 110011101 14 00001110 011001110 78 01001110 010011110 142 10001110 100011110 206 11001110 110011110 15 00001111 011001111 79 01001111 010011111 143 10001111 100011111 207 11001111 110011111 16 00010000 110101110 80 01010000 111000110 144 10010000 100100110 208 11010000 110100110 17 00010001 110101001 81 01010001 010110001 145 10010001 100110001 209 11010001 110110001 18 00010010 110101111 82 01010010 010110010 146 10010010 100110010 210 11010010 110110010 19 00010011 110100001 83 01010011 010110011 147 10010011 100110011 211 11010011 110110011 20 00010100 110101100 84 01010100 010110100 148 10010100 100110100 212 11010100 110110100 21 00010101 110101101 85 01010101 010110101 149 10010101 100110101 213 11010101 110110101 22 00010110 110100100 86 01010110 010110110 150 10010110 100110110 214 11010110 110110110 23 00010111 110100101 87 01010111 010110111 151 10010111 100110111 215 11010111 110110111 24 00011000 110101011 88 01011000 111000011 152 10011000 100100011 216 11011000 110100011 25 00011001 110001001 89 01011001 010111001 153 10011001 100111001 217 11011001 110111001 26 00011010 110000111 90 01011010 010111010 154 10011010 100111010 218 11011010 110111010 27 00011011 110001011 91 01011011 010111011 155 10011011 100111011 219 11011011 110111011 28 00011100 110001100 92 01011100 010111100 156 10011100 100111100 220 11011100 110111100 29 00011101 110001101 93 01011101 010111101 157 10011101 100111101 221 11011101 110111101 30 00011110 110001110 94 01011110 010111110 158 10011110 100111110 222 11011110 110111110 31 00011111 110001111 95 01011111 010111111 159 10011111 100111111 223 11011111 110111111 32 00100000 001101110 96 01100000 001001110 160 10100000 101101110 224 11100000 101001110 33 00100001 001101001 97 01100001 001001001 161 10100001 101101001 225 11100001 101001001 34 00100010 001101111 98 01100010 011010010 162 10100010 101101111 226 11100010 111010010 35 00100011 001100001 99 01100011 011010011 163 10100011 101100001 227 11100011 111010011 36 00100100 001101100 100 01100100 001001100 164 10100100 101101100 228 11100100 101001100 37 00100101 001101101 101 01100101 001001101 165 10100101 101101101 229 11100101 101001101 38 00100110 001100100 102 01100110 011010110 166 10100110 101100100 230 11100110 111010110 39 00100111 001100101 103 01100111 011010111 167 10100111 101100101 231 11100111 111010111 40 00101000 001101011 104 01101000 001001011 168 10101000 101101011 232 11101000 101001011 41 00101001 001011001 105 01101001 011011001 169 10101001 101011001 233 11101001 111011001 42 00101010 001011010 106 01101010 011011010 170 10101010 101011010 234 11101010 111011010 43 00101011 001011011 107 01101011 011011011 171 10101011 101011011 235 11101011 111011011 44 00101100 001011100 108 01101100 011011100 172 10101100 101011100 236 11101100 111011100 45 00101101 001011101 109 01101101 011011101 173 10101101 101011101 237 11101101 111011101 46 00101110 001011110 110 01101110 011011110 174 10101110 101011110 238 11101110 111011110 47 00101111 001011111 111 01101111 011011111 175 10101111 101011111 239 11101111 111011111 48 00110000 001100110 112 01110000 011100110 176 10110000 101100110 240 11110000 111100110 49 00110001 001110001 113 01110001 011110001 177 10110001 101110001 241 11110001 111110001 50 00110010 001110010 114 01110010 011110010 178 10110010 101110010 242 11110010 111110010 51 00110011 001110011 115 01110011 011110011 179 10110011 101110011 243 11110011 111110011 52 00110100 001110100 116 01110100 011110100 180 10110100 101110100 244 11110100 111110100 53 00110101 001110101 117 01110101 011110101 181 10110101 101110101 245 11110101 111110101 54 00110110 001110110 118 01110110 011110110 182 10110110 101110110 246 11110110 111110110 55 00110111 001110111 119 01110111 011110111 183 10110111 101110111 247 11110111 111110111 56 00111000 001100011 120 01111000 011100011 184 10111000 101100011 248 11111000 111100011 57 00111001 001111001 121 01111001 011111001 185 10111001 101111001 249 11111001 111111001 58 00111010 001111010 122 01111010 011111010 186 10111010 101111010 250 11111010 111111010 59 00111011 001111011 123 01111011 011111011 187 10111011 101111011 251 11111011 111111011 60 00111100 001111100 124 01111100 011111100 188 10111100 101111100 252 11111100 111111100 61 00111101 001111101 125 01111101 011111101 189 10111101 101111101 253 11111101 111111101 62 00111110 001111110 126 01111110 011111110 190 10111110 101111110 254 11111110 111111110 63 00111111 001111111 127 01111111 011111111 191 10111111 101111111 255 11111111 111101111 |