fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. uint8_t shift_reg = 0b101;
  5.  
  6. void print_bin(uint8_t value) {
  7. for (int i = 7; i >= 0; i--)
  8. printf("%d", (value & (1 << i)) >> i );
  9. putc('\n', stdout);
  10. }
  11.  
  12. void test(void) {
  13. shift_reg = (shift_reg >> 1) | ((shift_reg & 1) << 7);
  14. }
  15.  
  16. int main(void) {
  17. print_bin(shift_reg);
  18. test(); print_bin(shift_reg);
  19. test(); print_bin(shift_reg);
  20. test(); print_bin(shift_reg);
  21. test(); print_bin(shift_reg);
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 5388KB
stdin
Standard input is empty
stdout
00000101
10000010
01000001
10100000
01010000