Skip to content

Instantly share code, notes, and snippets.

@yshl

yshl/crc-16.bf

Last active Dec 11, 2015
Embed
What would you like to do?
-> # dec{0} @1
++++[->++++<]> # {2}=16 @2
[-[->>+<<]>>] # @34
->> # dec{34} @36
, # {36}=getchar()
+[- # while({36}!=neg 1){
<++++++++ # {35}=8 @35
[ # while({35}){
-> # dec{35} @36
[ # while({36}){
[->+>+<<]> # {37:38}={36} @37
[[-]>->+<<]> # if({37}){dec{38} inc{39}} @38
[-<+<+>>]< # {36:37}={38} @37
[[-]<->>>->+<<<]< # if({37}){dec{36} dec{39} inc{40}} @36
]>>>> # } @40
[-<<<<+>>>>]< # {36}={40} @39
[ # if({39}) {
-<<<<<< # dec{39} @33
[-<+>]< # {32}={33} @32
[->-<]> # {33}=neg{32} @33
+>>>>>> # inc{33} @39
]<<<<<< # } @33
[ # if({33}){
-<< # dec{33} @31
[->+<]> # {32}={31} @32
[-<->]< # {31}=neg{32} @31
+< # inc{31} @30
+[-<<+]-> # @1
+>>>> # inc{1} @5
[->+<]> # {6}={5} @6
[-<->]< # {5}=neg{6} @5
+> # inc{5} @6
+[->>+]-< # @33
]< # } @32
# p=30
+[- # while({p#2}!=neg 1){
< # @p#1
[->>+<<]< # {p#3}={p#1} @p#0
# p=sub p 2
+]->> # } @2
+[->>+]-> # @35
]> # } @36
, # {36}=getchar()
+]<<<< # } @32
+[-<<+]->> # @2
+++++++ # {2}=7 @2
# p=2
[ # while({p#0}){
- # dec{p#0}
[->>+<<]> # {p#2}={p#0} @p#1
[->>++<<]> # {p#3}=add {p#3} 2*{p#1} @p#2
# p=add p 2
]> # } @17
.> # putchar({17}) @18
+++++++ # {18}=7 @18
# p=18
[ # while({p#0}){
- # dec{p#0}
[->>+<<]> # {p#2}={p#0} @p#1
[->>++<<]> # {p#3}=add {p#3} 2*{p#1} @p#2
# p=add p 2
]> # } @33
. # putchar({33})
@yshl

This comment has been minimized.

Copy link
Owner Author

@yshl yshl commented Jan 20, 2013

CRC-16-IBM in Brainfuck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment