Skip to content

Instantly share code, notes, and snippets.

@mattcan
Created May 17, 2012 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattcan/2719365 to your computer and use it in GitHub Desktop.
Save mattcan/2719365 to your computer and use it in GitHub Desktop.
A program that counts to ten, outputting each value along the way
++++++++++ set loop counter to ten
[
>>>>+++ increase 5th cell by 3
<<<<- decrease loop counter
]
>>>>++ increase 5th cell by 2 to make the 'Space' ASCII code
<<<<++++++++++ reuse 1st cell as loop counter increase to ten
[
>+++++ increase 2nd cell by 5
>+++++ increase 3rd cell by 5
>+++++ increase 4th cell by 5
<<<- decrease loop counter
]
>-- 2nd cell = 48 :: ASCII for 0
>- 3rd cell = 49 :: ASCII for 1
>-- 4th cell = 48 :: ASCII for 0
<<<+++++++++ reset and reuse loop counter
[
>+. increase 2nd cell by 1 and ouput to screen
>>>. output the saved 'Space' in 5th cell
<<<<- decrease loop counter
]
>>. output 3rd cell = ASCII 1
>. output 4th cell = ASCII 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment