The MiMa is simulated in your browser. Once you submit code to the leaderboard, the code is simulated on the server as well.
It uses a 24-bit accumulator, 20-bit long addresses and 24-bit long data values.
Commands are made up of a 4-bit long command name, followed by 20 bits of data arguments.
The MiMa uses a shared memory space for data and instructions, and self-modifying code is possible.
Supported commands without arguments
HALT - stops the machine. Always include HALT somewhere in your program.
NOT - invert the data in the accumulator
RAR - rotate the data in the accumulator one bit to the right
Supported commands with one argument
DS c - just places the constant c into memory at the given address. Use this to store negative numbers, as using them in LDC will not work! LDC -1 cuts off the sign bit!
LDC c - loads a constant c into the accumulator
LDV a - loads the value behind an address a into the accumulator
STV a - stores the value in the accumulator at the address a
ADD a - adds the value behind the address a to the value in the accumulator
AND a - stores the result of a binary AND of the accumulator and the value behind the address in the accumulator
OR a - stores the result of a binary OR of the accumulator and the value behind the address in the accumulator
XOR a - stores the result of a binary XOR of the accumulator and the value behind the address in the accumulator
EQL a - stores minus one in the accumulator if the accumulator is equal to the value behind the address a, otherwise stores zero
JMP a - jumps to address a (sets the instruction pointer to address a)
JMN a - jumps to address a IF the accumulator is negative
LDIV a - indirect load; stores the value behind the value of the address a in the accumulator
STIV a - indirect store; stores the value in the accumulator behind the value of the address a
STIV and LDIV are extensions, but they are supported by default for now.
The MIMA-X extension is not supported yet, neither is MIMA Microcode.
Implementation details
Here are some implementation details you might consider useful:
Execution starts at the address given by the last
"\* = something"
, unless a START label is present
Any number of tabs or whitespaces is equivalent to one space
Comments start with ; and end where the line ends.
Labels must not point to empty lines
Label names must not include the = character.
Labels are not case-sensitive.
Number parsing:
0xnumber
and
$number
means that number is hexadecimal. Otherwise, numbers are decimal numbers.
The MIMA uses 24-bit numbers everywhere except addresses. Addresses are 20 bits long. Larger numbers are simply cut off at 24 or 20 bits respectively.
Define constants using NAME = VALUE syntax. They are not statements, do not get an instruction address and never enter the memory of the MIMA directly (only in the form of arguments to instructions).