Skip to content

Instantly share code, notes, and snippets.

@kotet
Created January 5, 2019 04:43
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 kotet/daeca8e99ca7e9521ea0ce00b527cca9 to your computer and use it in GitHub Desktop.
Save kotet/daeca8e99ca7e9521ea0ce00b527cca9 to your computer and use it in GitHub Desktop.
Stack and Heap in Brainfuck
stack and heap in brainfuck
result: 7 5 0 3 1 7
b1 == 5
b2 == 7
stack == [3 7]
>> allocate 2
>+++ push 3
push 5
>+
>+++++
<[<<] stack top to base
>>[>>]< base to stack top
pop and store to b1
[ <[<<] (<) + (>) >>[>>]< - ] <-<
push 5
>+
>+++++++
b2 = stack top
[ >>+<< <[<<] (<<) + (>>) >>[>>]< - ] >>[<<+>>-]<<
push b2 (nondestructive)
>+ [<<] (<<) [(>>) >>[>>] >+<<+ <[<<] (<<) -]
(>>) >>[>>]>
[<< <[<<] (<<) + (>>) >>[>>]> - ] <<
pop
[-]<-<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment