Dynamic Brainfuck


The Brainfuck programming language is arguably the most portable programming language of all time due to its simplicity. Brainfuck uses only eight operators and a tape of 8 bit cells to function: it's turing complete, but impossible to read or use practically. Here is the exhaustive list of operators and their descriptions.

Operator Description
< Move the pointer one cell to the left.
> Move the pointer one cell to the right.
+ Increment the current cell by 1.
- Decrement the current cell by 1.
[ Begin a loop while the cell at the pointer is not zero.
] Mark the ending of a loop body.
, Make the current cell equal to the next byte of input.
. Output the current cell as a byte.

Dynamic Brainfuck is a dialect of Brainfuck with six additional operators: 2 for dynamic memory management, 2 for emulating pointers and references, and 2 for better IO. Because of the additional operators, it is possible to use Dynamic Brainfuck as a target for a compiled high level language.

Operator Description
? Read the value of the current cell, and allocate that many cells at the end of the tape. Then, set the current cell's value equal to the index of first cell in that allocated block.
! Read the value of the current cell, and free the allocated cells starting at that index.
* Push the pointer to a stack, and set the pointer equal to the value of the current cell.
& Pop the old pointer off the dereference stack, and set the pointer equal to it.
# Make the current cell equal to the next integer in the input buffer.
$ Output the current cell as an integer.


Machine controls

Machine memory

    Input

    Output

    
        
                    

    Program