From Esolang
Jump to navigation Jump to search

minasm is designed by osminee in 2020. It's more like serious assembly language, however it has weird notation and lack of basic operations.

The machine

minasm machine have unbounded memory of unsigned integers. The processor has four registers: A Register (AR), B Register (BR), C Register (CR) and Operation Register (OR). AR, BR and CR are used to store data and for subroutines. Operation Register (OR) also stores data, but it can only be accessed by COP instruction. OR is used basically for conditional jumps. minasm has also registry called Instruction Pointer (IP), however it cannot be changed via instructions (except jump commands, which are the only way to change the value of IP).


Let's demonstrate the basics of minasm on this simple program:

` example program `
ADD (1) -1
JNZ (0)

First, all comments are removed (marked with `<comment>`). First instruction, COP OR 6 is like MOV instruction in x86 assembly: it COPies second argument to first one. So COP OR 6 copies value 6 to the Operation Register (OR). The second one, ADD (1) -1 ADDs second argument to first. In this example it adds value -1 to address 1 in hexadecimal, so it actually subtracts 1 from this address (parenthesis are used to denote that this number is physical address). Also, if you notice, this points to 6 in COP 6 OR, because COP takes 1 byte, as well as 6 and OR. Index of first value is 0, so 0+1=1. Next is JNZ (0). It jumps to specified byte if OR value is not zero. In this example, we initialize OR with value 6, so this condition would be satisfied and it would jump to byte 0. Last command is TER. It exits from program.

So basically this initializes Operation Register with value 6. Then it subtracts 1 from location 1 (pointing to 6), so it becomes 5. Then it checks if value in OR is not zero. If yes, then it goes to the beginning of the code. Else, it terminates the program.


Here are all instructions.

Name Usage Description
COP (COPy) COP <destination> <source> Copies <source> to <destination>
ADD (ADD) ADD <destination> <source> Adds <source> to <destination>
JMP (JuMP) JMP <byte> Jumps to specified byte in program and continues execution of program from that byte
JZ (Jump if Zero) JZ <byte> Checks the value in OR: if it's zero, jump to specified byte; else, continue execution of program normally
JNZ (Jump if Not Zero) JNZ <byte> Same as JZ, except it jumps if value in OR is not zero
TER (TERminate) TER Ends program
SUB (SUBroutine) SUB <number> Calls a subroutine (subprogram) with number <number>
DAT (DATa) (deprecated) DAT <number> Variation of COP: it gets replaced in code by <number>


Subroutines are built-in functions that are used to shorten code.