momiji
m68k emulator infrastructure
About Source codeTable of contents
momiji documentation
momiji is a cross-platform C++ library (and a set of tools) used to emulate m68k programs. The library includes functions for parsing, compiling and executing m68k code, there are also GUIs and CLI tools that wrap some of the common library’s features.
Use-case
Maybe you need an embeddable and easy to use Emulator class:
#include <momiji/Emulator.h>
#include <iostream>
int main()
{
momiji::Emulator emu{};
emu.newState(
"move.w #123, d0 \n"
"add.w #11, d0"
);
emu.step(); // Executes the move
emu.step(); // Executes the add
const auto& sys = emu.constStates().back();
std::cout << sys.cpu.dataRegisters[0].raw() << '\n';
}
Or maybe you want to inspect the instructions in a program:
#include <momiji/Parser.h>
#include <algorithm>
int main()
{
auto parsingResult = momiji::parse(
"move.w #123, d0\n"
"move.l #1, d1\n"
"add.l #1, a0"
);
if (!parsingResult)
{
// Error during parsing
// Get the error and handle it in some way
auto error = parsingResult.error();
// ...
return 1;
}
auto parsingInfo = *parsingResult;
// Count the number of instructions with the '.l' data type
const auto longs = std::count_if(
std::begin(parsingInfo.instructions),
std::end(parsingInfo.instructions),
[] (const auto& x) {
return x.dataType == momiji::DataType::Long;
}
)
std::cout << longs << '\n';
// Count the moves
const auto moves = std::count_if(
std::begin(parsingInfo.instructions),
std::end(parsingInfo.instructions),
[] (const auto& x) {
return x.instructionType == momiji::InstructionType::Move;
}
);
std::cout << moves << '\n';
// How many labels there are in the code?
std::cout << parsingInfo.labels.size() << '\n';
}
Whatever you may need, the library probably got you covered. If you think something is missing, please open an issue.
Building
The first thing you may want to do is build the library for your OS.
Tutorials
If you are new, this is the place for you. See the tutorials.
Guides
Public API Reference
Here you can find the public API reference for the library.
Private API Reference
Do you want to know how it all works or contribute? Here you can find the reference for the internal API of the library.
Troubleshooting
Contributing
Feel free to open an issue on Github or a PR