CSC 220 Program #3"MC Hamming code" Program #3 is:
|
|||
DescriptionYour task is to write two programs that use the Hamming code:
The Hamming code is discussed in our text on pages 73-77. Also, enjoy:
In short, the Hamming code is one flavor or an error-correcting code. Data is encoded with error-correcting information and then decoded. During the decoding process, any single-bit errors in the original data can be detected and corrected using the algorithm. The steps for encoding are:
The steps for decoding are:
Some detailsFor Program #3, let's use:
If you're ambitious you can increase your data word size to 16 bytes (128 bits). This is the maximum data word size that can be handled with 8 check bits using the Hamming algorithm. It's some extra work though. Note that the overhead in this case (128 bits of data) is only 6% (8/128).
|
|||
ImplementationIn our first programs, we almost exclusively dealt with 4 byte integers. Now, you have to be very aware of byte size. Including:
Reading & writing bytes of dataYou can use two C functions to read and write data 1 byte at a time. They are:
Notice that getchar() and putchar() deal with 4 byte quantities. The 1 byte read or written will be found in the lower byte of the 4 bytes. For more information and examples, try "help" on Microsoft Visual-whatever or google "getchar". Organizing the code wordIn my implementation, I found it easier to separate the check bits and the data word when creating my code word. Instead of the organization shown in the example above, I used the following setup:
The "Parity byte" is actually the 5 check bits padded with three zeros (000) on the front. Please note this choice is not required. I just found it easier to design the program this way. Lecture topicsI will lecture on the following topics:
Is this section a reminder for you or me?
|
|||
LogisticsGrading and logistics are the same as in Programs #1 and #2. You can implement your program in one large file or separate files. I recommend separate files. You simply need to supply gcc with each the files you have created to do the job: gcc file1.s file2.s file3.s Speaking of large, this is a larger and more complex program than the previous two. You can, if you like, start writing your program in C. You can use gcc to create assembly code for the C you have written: gcc -S file1.c The assembly code output by the compiler (file1.s in the example above) will need to be tweaked and commented, but it is a nice starting point. Please note that uncommented and/or unmodified compiler-generated assembly code will be graded harshly... but of course.
|
|||
Hints and moreI will provide a couple test cases of my own later this week. A fairly detailed example of Hamming code at work: Program #3 example
|