#include #include typedef unsigned char byte; struct crc8tab_t{ byte a[256] {}; // Generatorpolynom 0x31 = (1)00110001, constexpr crc8tab_t() { // revers (rechtsschieben) (1)00011001, const byte poly = 0x8C; // 1 rechts vorgeschoben 10001100(1) for (size_t x=0; x<256; x++) { byte crc=x; // würde man linksschieben, hier die Bitreihenfolge drehen for (byte b=0; b<8; b++) { if (crc&1) crc=crc>>1^poly; else crc>>=1; } // in Assembler " lsr crc\n brcc 1f\n eor crc,poly\n1:" a[x]=crc; // … und hier auch nochmal } } }; // Das füllt via Konstruktor den Flash mit den Bytes! constexpr PROGMEM crc8tab_t crc8tab; int main() { for (size_t x=0; x<256; x++) printf("%3u,",pgm_read_byte(crc8tab.a+x)); }