4 Revision 1.8 2000/01/05 08:20:39 markster
7 Revision 1.2 2000/01/05 08:20:39 markster
8 Some OSS fixes and a few lpc changes to make it actually work
10 * Revision 1.1 1996/08/19 22:32:07 jaf
16 #ifdef P_R_O_T_O_T_Y_P_E_S
17 extern int ham84_(integer *input, integer *output, integer *errcnt);
20 /* -- translated by f2c (version 19951025).
21 You must link the resulting object file with the libraries:
22 -lf2c -lm (in that order)
27 /* ***************************************************************** */
29 /* HAM84 Version 45G */
32 * Revision 1.8 2000/01/05 08:20:39 markster
33 * Version 0.1.9 from FTP
35 /* Revision 1.2 2000/01/05 08:20:39 markster
36 /* Some OSS fixes and a few lpc changes to make it actually work
38 * Revision 1.1 1996/08/19 22:32:07 jaf
41 /* Revision 1.3 1996/03/21 15:26:00 jaf */
42 /* Put comment header in standard form. */
44 /* Revision 1.2 1996/03/13 22:00:13 jaf */
45 /* Comments added explaining that none of the local variables of this */
46 /* subroutine need to be saved from one invocation to the next. */
48 /* Revision 1.1 1996/02/07 14:47:04 jaf */
49 /* Initial revision */
52 /* ***************************************************************** */
54 /* Hamming 8,4 Decoder - can correct 1 out of seven bits */
55 /* and can detect up to two errors. */
58 /* INPUT - Seven bit data word, 4 bits parameter and */
59 /* 4 bits parity information */
61 /* ERRCNT - Sums errors detected by Hamming code */
63 /* OUTPUT - 4 corrected parameter bits */
65 /* This subroutine is entered with an eight bit word in INPUT. The 8th */
66 /* bit is parity and is stripped off. The remaining 7 bits address the */
67 /* hamming 8,4 table and the output OUTPUT from the table gives the 4 */
68 /* bits of corrected data. If bit 4 is set, no error was detected. */
69 /* ERRCNT is the number of errors counted. */
71 /* This subroutine has no local state. */
73 /* Subroutine */ int ham84_(integer *input, integer *output, integer *errcnt)
75 /* Initialized data */
77 static integer dactab[128] = { 16,0,0,3,0,5,14,7,0,9,14,11,14,13,30,14,0,
78 9,2,7,4,7,7,23,9,25,10,9,12,9,14,7,0,5,2,11,5,21,6,5,8,11,11,27,
79 12,5,14,11,2,1,18,2,12,5,2,7,12,9,2,11,28,12,12,15,0,3,3,19,4,13,
80 6,3,8,13,10,3,13,29,14,13,4,1,10,3,20,4,4,7,10,9,26,10,4,13,10,15,
81 8,1,6,3,6,5,22,6,24,8,8,11,8,13,6,15,1,17,2,1,4,1,6,15,8,1,10,15,
84 integer i__, j, parity;
87 /* Parameters/constants */
88 /* Local variables that need not be saved */
89 /* Determine parity of input word */
90 parity = *input & 255;
91 parity ^= parity / 16;
95 i__ = dactab[*input & 127];
99 /* No errors detected in seven bits */
104 /* One or two errors detected */
107 /* Two errors detected */