Instructions
+
Adds TOS to NOS.
-
Subtracts NOS by TOS.
*
Multiplies NOS with TOS.
%
Gives the modulus from: NOS/TOS.
/
Division of NOS by TOS.
v
Set PC to down direction.
^
Set PC to up direction.
>
Set PC to right direction.
<
Set PC to left direction.
|
Pop TOS
If its TRUE (<> 0) then act as '^'
If its FALSE (= 0) then act as 'v'
_
Pop TOS
If its TRUE (<> 0) then act as '<'
If its FALSE (= 0) then act as '>'
$
Drop/pop top of stack.
:
Duplicates TOS.
Stack before: [30][5][1]
Stack after: [30][5][1][1]
\
Exchanges TOS and NOS.
Stack before: [30][5][1]
Stack after: [30][1][5]
g
Get a value from the map.
Arguments: (X)(Y).
Leaves the content of [MAP+X+Y] onto the stack, X and Y are removed from
the stack.
p
Put a value to the map.
Arguments: (VALUE)(X)(Y).
Sets the content of [MAP+X+Y] to (VALUE).
All arguments are removed from the stack.
"
Bistable stringmode switch.
All bytes from " to " gets pushed onto the stack as ascii values.
?
Generates a random direction and moves in that direction.
At random it behaves as a: '^','v','>' or '<'.
&
Input value from console, the integer value are pushed onto the stack.
~
Input character from console, the ascii value are pushed onto the stack.
.
Pop TOS and display on console as an integer.
,
Pop TOS and display on console as a character.
@
Exit program, leaves BF.
!
Inverts TOS.
If TOS is TRUE (<> 0), TOS becomes FALSE (0).
If TOS is FALSE (= 0), TOS becomes TRUE (1).
`
Greater than command.
Pops 2 values and compares these.
If NOS > TOS, then push TRUE (1).
If NOS <= TOS, then push FALSE (0).
#
Skip next instruction.
The phrase '2#9.' will output 2, since '9' is skipped (assuming a direction from left to right).
NOTES
Stack underflow
This befunge93 intepreter does not follow the stack underflow behaver of
most befunge intepreters.
The normal behaver is to return a value of '0' when a stack underflow occur.
This implementation does not, it is likely to crash if you operate it on underflows.
'..9' will overwrite the address STACK_END+4 with '9'.
Data area size
The data area is only 41x25.
The normal is 80x25, i find 41x25 to be easier to use with my terminal settings.
It could easily be changed, but i like to use this size.
I use the 41th byte to newlines, thus making it easy to edit my files.