Mimsy
Assembly with one Hand, where a jump finds its target by counting semicolons at run time.
Michael Patraw · Turing complete: unknown · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Michael Patraw named Mimsy after a word in Lewis Carroll's Through the Looking-Glass, which the specification reads as flimsy and miserable together. It looks like assembly, but nothing is worked out before the run. A jump does not name a label. It holds a count in the Hand and searches the code for that many ; ahead or behind, every time it runs.
Read the story
All work goes through the Hand. A program selects a place in memory with (...), then moves values between the Hand and that place, or combines the two. Memory has 256 locations, 250 for storage and six for the registers, and each one holds an integer, a float or a dynamic array of any of these, nested as deep as needed.
The machine
| Command | Does |
|---|---|
(3) (3,1) | Select location 3, or element 1 inside it |
(,1) (,) ($) | One level in, one level out, the path in the Hand |
(@) (*) (^) (?) | Select the Hand, the IP, the jump stack, the flags |
< > | Hand into the selection; selection into the Hand |
+ - * / % & ^ | | Selection op Hand, into the Hand |
= | Set the flags equal, not equal, less, greater |
$ , ~ ! | Length; grow or remove; negate; not |
@ : | Push or jump to the n-th ; from here, by the Hand |
' | Pop the jump stack into the IP |
? | Skip the next instruction when the selection is not 0 |
{name} name | Keep the Hand as a macro; put it back |
A backtick, ` , pushes the Hand on the jump stack. 5, _5, 2.5, [1 2] and "text" put a value in the Hand, _ being the minus sign. xPut prints the character in the Hand and xGet reads one, -1 at the end. The specification says ? runs the next instruction when the selection is not 0, but the comments of its examples and both of its programs need the opposite, and this implementation follows the programs.
The Code register, which holds the program and can be changed while it runs, is left out, since the specification does not say how an opcode looks as data. So is xOutputMemory, whose output the specification does not show.
Example
Hello, World! in two lines.
Hello, World! in two lines. It finds its own ; with 0@, keeps the place as the macro printString, and jumps there from the second line with the text in the Hand. A loop then prints the letters by an index kept in location 2, followed by a carriage return and a line feed.
A loop of its own. Location 0 counts from 48 to 57, and _1: jumps back to the ; just before it until the count reaches 58.
The cat prints location 0 before it reads anything, so its output starts with a 0 byte. The two worked examples end in xOutputMemory; up to there they leave 1024 and 10 in locations 0 and 1, and a hundred 5s in location 0, as their comments say.
Further
See also
Self-modifying
Cell-based
Write your own in Run Convert a program from Mimsy
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: mimsy.
Command line
shib run mimsy -e '(0)0<;(0)>xPut xGet(0)<_1=(?)(,0)_1?:' --input 'abc'shib manual mimsySource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/mimsy.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org