Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following program is used to determine the EVEN parity bit for a 7-bit data

ID: 2266020 • Letter: T

Question

The following program is used to determine the EVEN parity bit for a 7-bit data value. The parity bit is bit-7 and the data value is stored in bits 0 to 6, as shown below 0/1 7-bit data Parity bit ORG $8000 MOVE. B DATA, DO CLR.B D1 MOVE . B #8,D2 |LOOP ROR.B BCC ZERO ADDQ #1, D1 #1,DO 7 8 |ZERO SUBQ #1, D2 BNE LOOP 10 LSR . B #1,D1 BCC EXIT ORI.B #%10000000,D0 12 13 14 |EXIT TRAP #14 ORG $9000 15 DATA DC.B %10111011 16 odd Modify the above program so that it can determine the EVEN parity bit for a 7-bit data value. [4 points)

Explanation / Answer

In the above program the logic is as explained below:

1. Actual data is read into 8 bit D0 register and reduced to 7 bit by ANDING MSB with 0.

2. D1 is used as a count register to count 1's in given data.

3. D2 is initialized with value 8 (to shift out all 8 bits of D0 register)

4. Now D0 is rotated right and if carry is set it means lsb bit shifted out is 1 else 0. for every bit 1, D1 is incremented by 1 else just decrement D2 and repeat the loop till D2 doesn't become 0.

5. If number of 1's are odd then D1 lsb bit will be 1 else 0 for even number of 1's.

Hence if we replace instruction 12: BCC EXIT by BCS EXIT then above program will determine odd parity bit.