Beetle
Beetle is a virtual processor designed for the Forth language. It uses a byte-stream code designed for efficient execution which is binary portable between implementations. It has been implemented in C (see below) and assembler. The C implementation is completely machine-independent with the exception of interactive input and output; the assembler version runs the supplied Forth compiler at up to half the speed of the corresponding native code compiler and generates more compact code. Beetle is designed to be embedded in other programs; a simple debugger has been written to demonstrate this ability. Beetle can be configured to perform bounds checking on all memory references. A standard I/O library is implemented; access to native code routines is also possible, allowing Forth and C programs to call each other.
Papers
These are papers I have written about the Beetle Forth virtual processor and the associated pForth Forth compiler, which I developed for my BA dissertation project.
- An Introduction to the Beetle Forth Virtual Processor
- An introduction to the system; this is the best paper to read first. It was published in ACM SIGPLAN Notices February 1997.
- The Beetle Forth Virtual Processor
- The design of the Beetle Forth virtual processor is described. This is an implementor's guide, but it's probably also useful to programmers.
- An implementation of the Beetle virtual processor in ANSI C
- A portable ANSI C implementation of Beetle is described, with instructions for porting, compiling and running it.
- A simple user-interface for the Beetle virtual processor
- A user guide for a simple debugger shell for Beetle.
- Beetle and pForth: a Forth virtual machine and compiler
- My BA dissertation containing all the papers mentioned above, as well as a description of the project that produced them.
- Tradeoffs in the implementation of the Beetle virtual machine
- A hand-coded implementation of Beetle is described, and compared to the C version.
- Encoding literals in a portable byte-stream interpreter
- Various methods of encoding literal numbers in a byte stream are compared.
Program
This is the source distribution of C Beetle. All the relevant papers are supplied in DVI format. Email me if you have problems getting it to work.
- Source and documentation: Zip 134kb (includes hand-optimised ARM interpreter plus binary for RISC OS)