Has someone a good hint how to implement a parity-calculation of a byte in the most efficient way on an C51-device?
implement a parity-calculation of a byte in the most efficient way on an C51-device convert that routine to assembler, in assembler you have a parity bit in the PSW. That bit is not accessible in C since C is not register specific
Erik
"That bit is not accessible in C since C is not register specific"
The bit is accessible - the doubt is whether it relates to what you want at the time you want it...
Several people have suggested doing this in C51 - just do the Search to find it. You may be lucky, but I'd put it in an assembler function.
http://www.keil.com/support/docs/1619.htm
Great, thanks guys!
Hi,
Just have dealt with this problem recently.
May I share what I learned. One must calculate the parity right before using it. The ACC is a very busy fellow.
Ed.
"One must calculate the parity right before using it. The ACC is a very busy fellow"
Yes - that's why I urged caution in doing this in 'C':
"the doubt is whether it [the parity flag] relates to what you want at the time you want it..."
I still say assembler is preferable...
absolutely
Relying on a register in C is, at best, a kludge. Many will not use assembler because they believe that 'portability' is 'interesting' for code for small embedded, BALONEY. The only reason for using C with small embedded is coding and maintenance ease. Of course, a C function not using any I/O for small embedded is somewhat portable, but the C postulate that the whole shebang is portable is totally invalid for small embedded.
BTW how would ACC = Ralph; george = P; ever be portable.
PS if this is because you can not write it in assembler, I pity you.
View all questions in Keil forum