Beginner in assembly language on even and odd parity

63 Views Asked by At

I am unable to answer this question in my homework. Can somebody sample a solution I can reference to understand how to tackle this?

Initialize any random word in memory, e.g. 0x55555555. Only Bit 0 to Bit 30 are valid bits. Write assembly language code to generate the even and odd parity bit. Replace Bit 31 in the word with the parity bit. Write the Even Parity Word to r0 and Odd Parity word to r1. E.g. if the data in memory is 0x55555555.

  • Total number of 1’s is 16. Even Parity Bit = 0, Odd Parity Bit = 1.
  • r0 = 0x55555555
  • r1 = 0xD5555555

ive only managed to make a counter to count the number of 1s as hinted in my class but i am stuck on how to proceed from there.

1

There are 1 best solutions below

0
rcgldr On

pseudo code:

word        = memory word & 0x7FFFFFFF
count       = number of 1 bits in word
odd_parity  = count & 1
even_parity = 1 - odd_parity
r0 = word + (even_parity<<31)
r1 = word +  (odd_parity<<31)