BACK:
ESOTERIC LANGUAGES |
NEXT: BRAINFUCK - PART 2 |
INTRUCTION SYMBOL |
SYMBOL NAME (IN CASE YOU CAN'T SEE) |
FUNCTION |
+ |
PLUS |
Increment the value at the
Pointer. |
- |
MINUS |
Decrement the value at the
Pointer |
> |
GREATER THAN |
Move the pointer forward |
< |
LESS THAN |
Move the pointer backward |
[ |
OPEN SQUARE
BRACE |
Jump forward to the instruction
after the corresponding ]
if the value at the pointer is zero. |
] |
CLOSE SQUARE
BRACE |
Jump backward to the instruction
after the corresponding [
if the value at the pointer is not zero. |
. |
PERIOD |
Output the value at the pointer. |
, |
COMMA |
Put value of input (keyboard or
other type of input device) into the cell at the pointer. |
\/ + + + + + [ . - ] |
This
is the Program, which is stored as an array with as many entries as
necessary to hold the program. This program only requires 9 instruction
or 9 cells of program memory. The \/ above the first instruction marks
the instruction currently being considered by the computer. |
\/ 0 0 0 0 0 0 0 0 0 |
This is the free memory of the
machine, all initially zero when powered up. The pointer here is often
referred to as The Pointer and initially points to the first memory
location in the array. |
\/ + + + + + [ . - ] |
The
first instruction has already been executed. The computer automatically
selects the next instruction to be executed. |
\/ 1 0 0 0 0 0 0 0 0 |
The + command has raised the
value at The Pointer by one, but The Pointer has not moved and remains
still pointing to the first cell in the array. |
\/ + + + + + [ . - ] |
The
first five instructions have been executed. The computer now is ready
to execute the [ instruction which we have not discussed yet. |
\/ 5 0 0 0 0 0 0 0 0 |
The Pointer has still not moved
since neither a > or a < has been executed yet. Since five +
instruction have been executed the value at The Pointer has been raised
by 1 five times. |
\/ + + + + + [ . - ] |
The computer is now ready to
execute the last instruction in the program. |
\/ 4 0 0 0 0 0 0 0 0 |
The value at The Pointer was lowered by one from executing the - command. |
[
if the value at the pointer is not zero. Since the The Pointer is
clearly not pointing to a value of zero the machine jumps back to the
instruction right after the cooresponding [
.
BACK:
ESOTERIC LANGUAGES |
NEXT: BRAINFUCK - PART 2 |
>>HOME: >>OTHER CATEGORIES: |