1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-04 20:05:57 +00:00
8bitworkshop/tools/galois.c

24 lines
414 B
C
Raw Normal View History

2016-12-27 20:17:47 +00:00
/* test of 16-bit Galois LFSR */
#include "stdio.h"
int main()
{
int n = 100;
unsigned short x = 1;
for (int i=0; i<n; i++) {
int c = x&1;
x >>= 1;
if (c) x ^= 0xd400; // 0b1101010000000000
printf("%4x\n", x);
}
for (int i=0; i<n; i++) {
int c = x&0x8000;
x <<= 1;
if (c) x ^= 0xa801;
printf("%4x\n", x);
}
return 0;
}