"Stinkhorn" Befunge-98 and Trefunge-98 interpreter
I have resumed working on my old befunge-98 interpreter, which is undergoing changes for better compliance, performance, and features. I'm using the mycology test suite, which has proven very helpful so far in finding bugs.
Currently the following features are not supported: concurrent funge-98, exec, and quite a few fingerprints. I'll support whatever fingerprints I can shoehorn in, but don't expect TRDS to work any time soon. A CLI debugger is now included, although it still needs work. The debugger supports positional breakpoints, breakpoints based on what code is about to execute, and should shortly support more types of breakpoints.
The stinkhorn befunge-98 interpreter is currently all written in C++, and compiles under Visual C++ or G++. It supports befunge and trefunge, and cell sizes of 32 and 64 bits, both of which may be specified at run time. It is also possible to remove support for individual configurations at compile-time. See the usage section for details.
The two main goals are for it to comply with the Funge-98 specification, and be reasonably fast. Complete compliance will probably never happen, but I can try — it is especially difficult where the specification is not very clear on what the behaviour of an instruction should be. There is a reasonably infrequently updated source repository at http://svn.asztal.net/befunge98/.
The interpreter has a handprint of 0x5E5F5F5E. It's probably called “Stinkhorn”.
Downloads
- r50, Windows, x86, release mode, trefunge enabled, 32 and 64-bit cells enabled; md5sum: 25bb069b8fe567d0bdbb662dbfe0ce30
- r50, Windows, x64, release mode, trefunge enabled, 32 and 64-bit cells enabled; md5sum: 8f4dd7565504eaed7cd8dc54477d4e4f
Supported Fingerprints:
- HRTI — with microsecond accuracy only on windows... so far
- ROMA
- NULL
- TOYS (except the J and O instructions, for now)
- REFC
- ORTH
- MODU
- ORTH
- BOOL
- SOCK
- STRN
Using stinkhorn
$ ./stinkhorn --help
General options:
--help [ -h ] produce help message
--version [ -v ] produce version message
--warnings [ -w ] turn on warnings
--befunge-93 [ -93 ] befunge-93 compatibility
--cell-size [ -B ] arg change the cell size (default 32)
--trefunge [ -3 ] use trefunge instead of befunge
--source-line [ -S ] specifies the source code inline, instead of reading
from a file. May be specified again to specify the
next line of the source. Note: ^, <, > and " must
usually be escaped.
--show-source-lines useful for debugging --source-line
--debug [ -d ] attach debugger
--bench [ -b ] benchmark by running until 2 seconds has elapsed
--benchn arg benchmark by running the given number of times
How to build
First of all, the boost c++ library is required (you don't need to actually build it, though, only the headers are used). To build: on windows, with Visual Studio, build the MSVC project; on anything else, g++ -o stinkhorn -O2 *.cpp. If it doesn't build with your compiler, it's probably because I've written non-standard C++ and not noticed because of lenient compilers. Please feel free to tell me if this happens.Using the debugger
To use the debugger, pass the -d argument to the interpreter. Once inside the debugger, use the help command to obtain a list of commands and help command to obtain information about a particular command (note: it may not be very useful information).
The list (or just l) command shows the fungespace at a given point (which defaults to where the current IP is). The size of the output of list is configurable using the listsize command. The output of list should look something like what is shown above if you have images enabled. The IP's current position is shown by the "crosshair" of yellow characters surrounding it, the IP's recent positions are shown in magenta, and the predicted next instruction is red. This gives a vaguely usable visual indication of the IP's position and direction. The yellow crosshair will probably change to some other indication in the future, since it kind of sucks.
The debugger doesn't currently support multiple threads, but that's OK, since the normal interpreter doesn't do that yet either. All in good time.
Recent changes
- Added STRN fingerprint (a somewhat naïve implementation).
- Fixed the funge-space code, which was even more broken than I thought. It's probably still broken.
- Performance enhancements when advancing through funge-space page boundaries.
- Added a "trail" command to the debugger to show the path the IP has taken recently.
- Changed the debugger's "l" command to show the IP's trail and the cell it will visit next. (This may need changes when the debugger actually supports more than one thread.)
- Added the SOCK fingerprint, which has currently only been tested on windows.
- Fixed some broken project settings (oops.)
- Changed the code structure and explicit template instantiation methods. The new structure extracts the cell size and funge-space dimensionality into template parameters. The new template structure allows referring to dependent names without having to explicitly qualify them, and is bad but probably more maintainable than the alternative, which is explicitly qualifying most names, which would probably have been necessary otherwise due to C++ being slightly weird sometimes.
- Multiple changes so that it actually compiles under GCC once again.
- Program now quits properly instead of using exit(), so that destructors are called.
- Fixed a bug when calling ) in a different order to (.
- HRTI: Fixed a bug in S where the result might be negative, and in G where the result might be 0.
- Fixed a bug in y where the environment variables would be missing if the parameter was nonpositive.
- Added warning for some command line options and fixed the slightly broken parser.
- Added the BOOL fingerprint.
- Renamed to Stinkhorn since sponge already existed.
- Started actually keeping track of changes.