Advertisement
STANAANDREY

lfsr high lvl

Oct 21st, 2024 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define MASK 12
  4. #define SEED 15
  5.  
  6. unsigned LFSRshift(unsigned lfsr) {
  7.     unsigned feedback = lfsr & 1;
  8.     lfsr >>= 1;
  9.     if (feedback == 1) {
  10.         lfsr ^= MASK;
  11.     }
  12.     return lfsr;
  13. }
  14.  
  15. int main() {
  16.     unsigned lfsr = SEED;
  17.     do {
  18.         lfsr = LFSRshift(lfsr);
  19.         printf("%u ", lfsr);
  20.     } while (lfsr != SEED);
  21.     putchar('\n');
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement