Has someone a good hint how to implement a parity-calculation of a byte in the most efficient way on an C51-device?
Here's a simple one:
static char const code nibble_parity[16] = { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; char calc_even_parity(uchar byte) { return( nibble_parity[byte&0xf] ^ nibble_parity[(byte>>4)&0xf]); } char calc_odd_parity(uchar byte) { return(!calc_even_parity(byte)); }
I've been using it for years