2B
Jump to navigation
Jump to search
2B is an esoteric programming language created by user:David.werecat in which memory is stored in a tape where each cell is a separate tape of bytes.
Instructions
During these examples, the character "
represents any number from 0-9 and the character _
represents a string of any length. Whenever 0 is used, it is interpreted as 10.
Instruction | Description |
---|---|
0 |
Zeros the current cell. This function also clears the overflow flag. |
{ |
If the current cell is zero, jump to the matching }. |
} |
Do nothing. A placeholder for the { instruction.
|
( |
Read a byte from input and place in the current cell. |
) |
Write the current cell's value to the console. |
x |
Stores the value of the current cell in a temporary register. |
o |
Writes the value in the temporary register to the current cell. |
! |
Performs a carry operation. If the last addition overflowed, then increment the current cell by one. If the last subtraction underflowed, the decrement the current cell by one. |
? |
Performs a binary NOT on the current cell. |
+" |
Adds an amount to the current cell. |
-" |
Subtracts an amount from the current cell. |
^" |
Moves the subtape up a number of times. |
v" |
Moves the subtape down a number of times. |
<" |
Moves the tape left a number of times. |
>" |
Moves the tape right a number of times. |
:_: |
Defines a label with name _. |
*_* |
Jumps to a label of name _. If the label is not within the current function, then the behavior of the jump is undefined. |
@_@ |
Calls a function of name _. |
~_~ |
Defines a function of name _. The function is treated as a separate chunk of code, so functions can be defined anywhere. |
% |
Ends a function definition. |
#_# |
Is a comment. |
Spaces are treated as NOPs. Any tabs or newlines are interpreted as whitespace and removed before interpreting.