ASCII PARITY Encoder

Status
Not open for further replies.
Hi,
I have to write a program of EVEN 7-bit ASCII parity encoder
the 8 bit use for encoding purposes
have to convert 8th bit to even parity encoder
1st byte is located at RAM
Program out put shouldn't consist more than 10 bits

Have to use ASCII control character EOT
not sure on how to start
Any help will be great
thanks for your help
will be helpful if can suggest what to look for (any particular topic on this) which will help
thanks
 
Last edited:
Start by deciding which processor, language, compiler etc you will use. Then count the number of 1 bits in your 7 bits and make the eight bit 1 if the number of 1 bits is 0,2,4, or 6, otherwise zero.

Mike.
 
Start by deciding which processor, language, compiler etc you will use. Then count the number of 1 bits in your 7 bits and make the eight bit 1 if the number of 1 bits is 0,2,4, or 6, otherwise zero.

Mike.
Thanks for your reply.
Will use SDK 85
 
Seems odd this.... We are talking about 7 bits not 8.... so it can never be even....
 
Seems odd this.... We are talking about 7 bits not 8.... so it can never be even....

The number of bits set to 1 can be even.

Here is an algorithm to count "ones" in a char:

C:
int count_ones(unsigned char x) {
   x = x - ((x >> 1) & 0x55); 
   x = (x & 0x33) + ((x >> 2) & 0x33); 
   x = (x + (x >> 4)) & 0x0F; 
   return x & 0x3F; 
}
 
Last edited:
I cant see how....
Here is an algorithm to count "ones" in a char:

Its not a char if it only has 7 bits... Unless you assume the eighth bit was a zero..

4 ones, 2 ones etc.. as Mike said... But neglecting that eighth bit, an odd number of bits can NEVER have an even parity.

I always assumed that the level of 1's and 0's set the parity, not 0,2,4 6 and 8 1's
 
Program out put shouldn't consist more than 10 bits
I thought you had an 8-bit data-width (the 8th bit being parity)?

I always assumed that the level of 1's and 0's set the parity, not 0,2,4 6 and 8 1's
According to Wikipedia:
"In case of even parity, the parity bit is set to 1, if the number of ones in a given set of bits (not including the parity bit) is odd, making the number of ones in the entire set of bits (including the parity bit) even. If the number of ones in a given set of bits is already even, it is set to a 0."
 
Last edited:

Ok I concede..

Mike is right... Mr T's also right...
 
the 8 bit is dnt care mode...
Even or Odd wouldn't matter ..so can do it either way...which ever is less complex...
 
this is the chart I found on Wikipedia
7 bits of data (count of 1 bits) 8 bits including parity
even odd
0000000 0 00000000 00000001
1010001 3 10100011 10100010
1101001 4 11010010 11010011
1111111 7 11111111 11111110
 
That chart has the most significant bit in the rightmost position. I (and most others) write binary and decimal with the most significant digit (bit) in the leftmost position. So your chart would become,
Code:
Decimal    Binary       bits    Even            Odd
0          0000000	0	00000000	10000000
81         1010001	3	11010001	01010001
105        1101001	4	01101001	11101001
127        1111111	7	11111111	01111111

HTH

Mike.
 
yeah much better now
thanks
 
What Mr T is saying is Don't care is usually a little "x"

Ie.. x1111111 = 0x7F.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…