What Is Mahatma68k ?
Mahatma68k is an emulation library for the Motorola 68000 for the Java Virtual Machine. It was developed out of the necessity to have a reliable, easy to integrate and efficient emulation for this platform.
First and foremost, Mahatma68k was written for people who want to write an emulator of an 68000 based system (e.g. Amiga, Atari ST, Genesis, NeoGeo) on the Java Virtual Machine in order to take advantage of its portability, performance and the possibility to use a large number of different JVM-based programming languages.
It also targets people who want to learn about machine programming on a processor design which at the time of its publication (1979) was extremely advanced and simple to program at the same time.
- clear, efficient design and implementation
- flexible, so it can be integrated into other projects easily
- comprehensive documentation to make it easier for users to take advantage of the library.
Getting the code
The source code and precompiled binaries can be obtained from the project's Sourceforge page.
Building the emulator library
Maven 2 and Ruby are required in order to build the library from source.
Steps to build
After either checking out the source or unpacking it from the archive,
- change to the project's directory
This creates the target jar file in the
target directory, and also installs it in your local maven repository.
Hint: executing the generator with the
-slim option creates an emulation without disassembly functionality. The resulting code will be about half the size, but toString() will not display the disassembled instruction anymore
How to use the library
In order to use Mahatma68k in a project, it needs to be in your project's class path. IDE like Netbeans, Eclipse or IntelliJ have a feature to manage libraries, so if you are using an IDE to build your project, you could define Mahatma68k as a library and reference it from your project.
If you are building with maven or ant, the library should be in both the project's compilation and run class path. Please consult your build tools documentation how to do so.
TODO: Example program
Mahatma68k achieves performance by moving the decoding phase out of the emulator. A generator contains information about decoding, timing and disassembly and generates a large class file in which the decoding step is simply a lookup in a large array. Each array entry represents a combination of the operation, the addressing mode(s), instruction size (byte, word, long) and register numbers. When running larger 68000 programs, the array lookup is much more efficient than having to decode each instruction over and over again, leaving more performance reserves for the other components of the emulated system. This concept is not new: It is found in other 68000 emulators such as Musashi (used in MAME) or the UAE 68000 emulation. In fact, Mahatma68k was inspired by these emulators. The setup of the instruction database and the implementation are quite different, however (also caused by using different implementation languages, namely Ruby and Java).
The current implementation supports about 85% of the Motorola 68000's instruction set and more than 90% of the ones that are relevant for practical use. It is used as the centerpiece of the Amiga emulation project Dream Machine Preservation Project and is therefore regularly enhanced and improved.
Click on the following image to upload a new version of the PNG logo image for your project: