0

I am having difficulty with this and am having no luck and would appreciate any help!! Thanks

The Hamming code is a special technique for encoding and decoding information to enable error detection and correction. Richard Hamming published his work in 1951. The high cost of hardware in the past made this technique costly and, therefore, not practical. A CRAY computer design was released to the marketplace which uses single error correcting techniques as described in the Hamming paper.

Encode

A significant feature of the Hamming code is that all components of the algorithm are mathematically sound and practical. The encoding procedure is to compute “even parity” bits based on the information to be transmitted and send those parity bits along with the transmitted information. If the information contains 4 bits (abcd), then three parity bits (rst) are needed. These parity bits are called check bits. The encoded message is then structured as:

position    7   6   5   4   3   2   1
bit a   b   c   r   d   s   t

where:

r is set to create even parity for bits 7, 6, 5 and 4;
s is set to create even parity for bits 7, 6, 3 and 2;
t is set to create even parity for bits 7, 5, 3 and 1.

You are to encode the contents of a byte in memory where the information bits a, b, c and d are located as shown in the following:

xxxxabcd

For example, suppose that you have the following memory configuration, your task would be to compose the encoded bytes as shown:

memory encoded message

2274    xxxx1011    01010101
2275    xxxx1001    01001100
2276    xxxx0011    00111110

1 Answers1

0

The simple answer is to use a Look Up Table (LUT) to do the encoding (and also the decoding)

START:
        LEA     INPUT,A1
        LEA     OUTPUT,A2
        LEA     ENCODE,A0
ENCLOOP:
        MOVE.B  (A1)+,D0
        BMI.S   EXIT
        AND.W   #$0F,D0
        MOVE.B  (A0,D0.W),D1     ; encode byte
        MOVE.B  D1,(A2)+         ; save it
        BRA.S   ENCLOOP

EXIT:
        SIMHALT
        ; change table to match your Hamming scheme
ENCODE: DC.B $2E,$AD,$14,$97,$B2,$31,$98,$1B
        DC.B $E4,$67,$CE,$4D,$68,$EB,$52,$D1
INPUT:  DC.B $0B,$09,$03,$FF

OUTPUT: DS.B 3
vogomatix
  • 4,856
  • 2
  • 23
  • 46