HAM Version 1.0 TURBO Pascal (tm) October 23, 1984 Adam Fritz 133 Main Street Afton, New York 13730 HamE(ncode) and HamD(ecode) may be used for non-commercial purposes only. No commercial use of this document or these programs may be made without the author's express written permission. The programs HamE 1.0 and HamD 1.0 implement a version of Hamming error detection and correction coding. These programs are written in TURBO Pascal 2.0 and intended for CP/M 2.2 (tm) compatible environments. The reference explains the concept and mathematics for a class of codes intended to preserve information by using care- fully composed 'parity' bits carried with the information to detect and correct error. The code applied here is Hamming (8,4) and is used to encode 4 bit nibbles into 8 bit bytes such that two bit errors are detectable and one bit errors are correctable. Another presentation of this topic is found on some bulletin boards. Files HAMMING.DOC and FORMHAM.ASM by Rod Hart present introduction and code. USAGE ===== The text in file TEXT is encoded into CODE ; A>hame code and decoded into CLEAR ; A>hamd clear EXAMPLE ======= The filter GREMLIN reads its input, flips bits at intervals uniformly distributed over a specified interbit distance, and writes to the output. The command; { Copyright (C) 1984 Adam Fritz, 133 Main St., Afton, N.Y. 13730 } { Copyright (C) 1984 Adam Fritz, 133 Main St., Afton, N.Y. 13730 } A>gremlin -d37 gremlin -d64 hame code A>gremlin -d64 corrupt A>hamd clear Hamming encode file TEXT, corrupt the encoded file by flipping about every 32nd bit, and decode the corrupted file into CLEAR. GREMLIN reports; (0) 591 (1) 169 (2) 7 (3) 1 (4) 0 (5) 0 (6) 0 (7) 0 (8) 0 which means there are 768 bytes in the corrupted file, 591 of which are unchanged, 169 have one bit flipped, 7 have 2 bits flipped, and 1 has 3 bits flipped. HAMD reports; Errors Detected: 177, Errors Corrected: 170 so it appears that all errors were detected but that the 3 bit error may have been treated as a single bit error and some { Copyright (C) 1984 Adam Fritz, 133 Main St., Afton, N.Y. 13730 } { Copyright (C) 1984 Adam Fritz, 133 Main St., Afton, N.Y. 13730 } correction performed. The decoded file CLEAR; We 4he People of the United States, in order to form a more& perfect Union, establish Justice, insure domestic Tranquility, provide f-r the common defence, promotm the general Welfare, and secure the Blessings of Libertypto ourselves and our Posterity, do ordain and establish this Constitution for the Unitgd States of America. which is clearly still usable. Similar commands, but using 32 for GREMLIN's parameter, report; (0) 434 (1) 300 (2) 29 (3) 4 (4) 1 (5) 0 (6) 0 (7) 0 (8) 0 and Errors Detected: 333, Errors Corrected: 303 for GREMLIN and HAMD, respectively, and file CLEAR appears; We the"People of the Uniqmd^@States, In order to form a more+ perfect Umijn,0ectablish Justice, insure domestic Tranquility, ^]^J provide fo2 the common defence$ promote thd ge~eral Welfare, and segure the reessingz of Libgrty to ouRselves and,our Posterity, d/ ovdein and establish this Constitution for the United States of America. Using 16 for GREMLIN's parameter reports for GREMLIN; 768 (0) 208 (1) 409 (2) 133 (3) 17 (4) 1 (5) 0 (6) 0 (7) 0 (8) 0 and for HAMD; Errors Detected: 560, Errors Corrected: 430 and CLEAR appears; We the!P5opl` f the Wnyted [6adeS, mn orge2 to for} a mowe =^J perfec| Unaen, esthblish JuwdicE, ijsuve d/mestIc T{enqwi^Lity, ^O^A provi$e fob the$co}mon tafe~SE, pr/-ode'the genural S/l&arw,`and` secur% tbeAKlessIggw f Libebti to ourselves`and Our Pkstesid{, dO ordain afl esta`lisH THisaGonsti~utikn"f/r thd United Stave ^L of!Amerifan-^J For practical purposes, this degree of corruption makes the file unusable. Consider, however, what happens to TEXT when directly corrupted to this intensity; WE(phm`PmgPlm`kv#4`a W~ytdd"Svadus$$im^@opdws uo &obe #!oord ^N^X pmzfdad ^]l)o~, usEcb-mqx Nu[xIcel()n{}bedDkMmstib00rqjp=inivy= ^I^Z { Copyright (C) 1984 Adam Fritz, 133 Main St., Afton, N.Y. 13730 } { Copyright (C) 1984 Adam Fritz, 133 Main St., Afton, N.Y. 13730 } qrn^)du corbtle$commkn!Deve~c^Gn$pVolnvM dhd!gdn$rqd Vumf`R%.^D affr/^JS-1uve(t)e"JlmSwigg;`on H)bEB4y$|/`otsSulVas$and kws"@/rtlp+ t(, -^Jf.^@grlayN$add"es4a"l}sj`tlQ{ JLn2di|uuIoj(fgr!tme^BU~ivme$Qvi 4%s0mn$Aoevace.^I* Filter BF counts the occurences of byte codes appearing in its argument files and reports the results file by file to the standard output. If no argument file appears then it uses the standard input. By using BF it is possible to see what HAME is doing; A>hame hame clear QUESTION ======== i. Does it make any difference how the parity bits are inter- laced with the data bits in the code word? Suppose that the bit errors are not uniformly distributed over some interbit distance but rather that bit errors are serially correlated and modeled with a 'bursty' gremlin. ii. Can error resistance be improved by nested encodings? For example; A>hame clear REFERENCE ========= Error-Correcting Codes W. Wesley Peterson The M.I.T. Press, 4th Printing, 1968 Chapter 5, Example 2, pg. 65 et seq TURBO Pascal (tm) Borland International MS-DOS Microsoft CP/M (tm) Digital Research { Copyright (C) 1984 Adam Fritz, 133 Main St., Afton, N.Y. 13730 }