Created
December 30, 2016 04:26
-
-
Save WesleyAC/fce000f65c7acc9b7b6b7bb4dc04c2b8 to your computer and use it in GitHub Desktop.
Cracklepop in brainfuck
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
CracklePop in brainfuck | |
Memory architecture: | |
00: "\n" | |
01: "p" | |
02: "o" | |
03: "P" | |
04: "e" | |
05: "l" | |
06: "k" | |
07: "c" | |
08: "a" | |
09: "r" | |
10: "C" | |
11: hundreds counter | |
12: tens counter | |
13: ones counter | |
14: ones char | |
15: tens char | |
16: hundreds char | |
17: '\n' | |
18: zero, used in mod algo | |
19: bit counter for main loop | |
20: zero/bit counter location after mod algo | |
21: Number to mod by for mod algo | |
22: zero/result of mod algo | |
23: zero, used in mod algo | |
24: zero, used in mod algo | |
25: mod count bit - counts number of times that n mod a has returned zero | |
26: tmp | |
27: tmp | |
28: print hundreds | |
29: tmp | |
30: tmp | |
31: print tens | |
32: tmp | |
33: tmp | |
32: stop bit | |
33: tmp | |
34: tmp | |
] | |
# STATIC DATA SETUP | |
+++++ +++++ > # \n | |
> +++++ +++++ [ <+++++ +++++ +> -] < ++ > # p 10x11p2 | |
> +++++ +++++ [ <+++++ +++++ +> -] < + > # o 10x11p1 | |
> +++++ +++++ [ <+++++ +++> -] < > # P 10x8 | |
> +++++ +++++ [ <+++++ +++++> -] < + > # e 10x10p1 | |
> +++++ +++++ [ <+++++ +++++> -] < +++++ +++ > # l 10x10p8 | |
> +++++ +++++ [ <+++++ +++++> -] < +++++ ++ > # k 10x10p7 | |
> +++++ +++++ [ <+++++ +++++> -] < - > # c 10x10m1 | |
> +++++ +++++ [ <+++++ +++++> -] < --- > # a 10x10m3 | |
> +++++ +++++ [ <+++++ +++++ +> -] < ++++ > # r 10x11p4 | |
> +++++ +++++ [ <+++++ ++> -] < --- > # C 10x7m3 | |
-- > # Hundreds counter | |
----- ----- > # Tens counter | |
----- ---- > # Ones counter | |
> +++++ + [ < +++++ +++ > -] # Ones char | |
> +++++ + [ < +++++ +++ > -] # Tens char | |
> +++++ + [ < +++++ +++ > -] # Hundreds char | |
# END STATIC DATA SETUP | |
<<<<<< # go back to hundreds counter | |
[ # Hundreds loop | |
>[ # Tens loop | |
>[ # Ones loop | |
>+< # Increment ones value | |
>>>>>+<<<<< # Increment bit counter | |
>>>>>>>>>>>>>>>>>>>> >[-]+ >[-]<< [>-]>[< | |
<<<<<<<<<<<<<<<<<<<< | |
>>>>[-]>>[-]>[-]+++>[-]>>[-]>[-]<<<<<< # Setup for mod3 algo (including zeroing the mod count) | |
[>+>->+<[>]>[<+>-]<<[<]>-] # mod | |
>[-<+>] # Move bit counter back | |
>> # Move to mod result | |
>[-]+ | |
>[-] | |
<<[ | |
mod is nonzero | |
>-]> | |
[< | |
mod is zero | |
<<<<<<<<<<<.<.<.<.<.<.<.<<<>>>>>>>>>>>>>>>>>>>> # Print Crackle | |
>>>+<<< # Increase mod count | |
>->]<< | |
<<<<<<<< # Everything returned to the way it should be for the next mod operation | |
>>>>[-]>>[-]>[-]+++++>[-]>>[-]<<<<< # Setup for mod5 algo | |
[>+>->+<[>]>[<+>-]<<[<]>-] # mod | |
>[-<+>] # Move bit counter back | |
>> # Move to mod result | |
>[-]+ | |
>[-] | |
<<[ | |
mod is nonzero | |
>-]> | |
[< | |
mod is zero | |
<<<<<<<<<<<<<<<<<<.<.<.>>>>>>>>>>>>>>>>>>>> # Print Pop | |
>>>+<<< # Increase mod count | |
>->]<< | |
<<<<<<<< # Everything returned to the way it should be for the next mod operation | |
>>>>>>>>>>> # Move to mod count | |
>[-]+ | |
>[-] | |
<<[ | |
mod counter is nonzero | |
>-]> | |
[< | |
mod counter is zero | |
>>> >[-]+>[-] <<[ <<<<<<<<<<<.>>>>>>>>>>> >-]>[< >->]<< <<< # Print hundreds and set stop bit | |
>>>>>> >[-]+>[-] <<[ <<<<<<<<<<<<<<<.>>>>>>>>>>>>>>> >-]>[< >->]<< <<<<<< # Print tens | |
<<<<<<<<<<.>>>>>>>>>> # Print ones | |
>->]<< | |
>>> >[-]+>[-] <<[ >>>>>>+<<<<<< >-]>[< >->]<< <<< | |
<<<<<<<<<<< | |
<<<<<<<<<<<<<.>>>>>>>>>>>>> # Print newline | |
>>>>>>>>>>>>>>>>>>>> >->]<< | |
<<<<<<<<<<<<<<<<<<<< | |
+]< | |
>>----- -----<< # Reset ones char | |
>----- -----< # Reset ones counter | |
>>>+<<< # Increment tens value | |
>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<< # Increment print tens | |
+]< | |
>>>>----- -----<<<< # Reset tens char | |
>----- -----< # Reset tens counter | |
>>>>>+<<<<< # Increment hundreds value | |
>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<< # Increment print hundreds | |
+] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment