1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-23 03:29:39 +00:00
8bitworkshop/tools/galois.c
2016-12-27 15:17:47 -05:00

24 lines
414 B
C

/* 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;
}