MinISCule
One instruction of five bytes, run by an MS-DOS program of 36 bytes.
Jeffry Johnston, 2006 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Jeffry Johnston made MinISCule in 2006 to have a very small interpreter for a Turing complete language. The interpreter is an MS-DOS COM file of 36 bytes, written in DEBUG. MinISCule is a one instruction set computer with an instruction pointer IP and a memory pointer MP.
Read the story
Every character of a program is a byte, its code less 78. So N is 0, O is 1, M is -1 and ~ is 48. Every five bytes are one instruction.
The machine
An instruction has an address of two bytes, a value of one byte and a jump of two bytes, each low byte first. It runs in five steps.
- Add the address to MP.
- If the value is 0, call MS-DOS INT 21h with AX the address and DL the byte at MP.
- Add the value, or the AL the call returns, to the byte at MP.
- Add 5 to IP.
- If the byte at MP is not 0, add the jump to IP.
The address is also the number of the DOS function. 00h ends the program, 01h reads a character and 02h writes one, so a write with AX 0200h moves MP 512 bytes on as well. A move without a call has to add something other than 0 on the way.
This implementation has the DOS functions 00h, 01h, 02h, 06h, 07h, 08h and 4Ch and no others. Its memory is 64 KB of zeros and does not hold the program, and MP starts at 0.
Example
The program prints A.
The program prints A. It moves MP 512 bytes up, adds 1 and clears the byte with a loop that subtracts 1 and jumps back 5 bytes until it is 0. It adds 48 and 17 to make 65. Then it moves 512 bytes down, adding 1 and taking it off again, so that the write with AX 0200h lands on the A. The last five bytes call function 00h.
The same steps print more. The H is 48 and 24 in a fresh byte, f standing for 24, and the i is 48, 48 and 9, W standing for 9.
Patterns it teaches
- One instruction: move, add and jump in one, with the operating system behind a value of 0.
- Turing tarpit: the language exists to make its interpreter small.
Further
See also
OISC
Write your own in Run Convert a program from MinISCule
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: miniscule.
Command line
shib run miniscule -e 'NNNNN'shib manual minisculeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/miniscule.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org