UM8

From Esolang
Jump to navigation Jump to search
This article is a stub, which means that it is not detailed enough and needs to be expanded. Please help us by adding some more information.

UM8 a virtual machine created by User:Palaiologos for an Esolang reverse-engineering contest. The contest has finished in July 2020.

It contains 13 instructions ranging from 0x0 to 0xd. The original interpreter will take ASCII hexadecimal input from stdin (in uppercase). If it encounters something else than [0-9A-D] it will stop taking input and proceed to execution.

The machine contains 3 registers: A, B and C. The instruction sets permits self-modification of the program buffer, implying the program buffer can also be used as a tape for data storage or just modifying code in general.

Instruction set (credit: Gibson)

The instruction reference is written as some pseudo-code.

  • a, b, c are the registers
  • pc is the program counter
  • [expr] points at (expr) in the program buffer
  • ; are comments/notes from me
0 -> exit()
1 -> if (b) a = c
2 -> swap a, c
3 -> a = ~(b&c) ; NAND gate
4 -> putchar(b)
5 -> b = getchar()
6 -> swap a, b
7 -> a = [pc+c+1]
8 -> [pc+a+1] = b
9 -> a = [++pc]
A -> pc = b, [pc] = c
B -> a = !a ; logic NOT
C -> a >>= 1
D -> a <<= 1

NOTE Due to the way the interpreter is implemented, A jumps to b+1 and not b. However, [b] will still be set to c.

Example Programs

Cat

154906A

Here is a commented disassembly to understand it better:

1  | if (b) a = c      ; "dummy" instruction
5  | b = getchar()     ; get character from stdin
4  | putchar(b)        ; prints it
90 | a = 0
6  | a, b = b, a       ; sets b to 0
A  | pc = b, [pc] = c  ; jumps to 1, modifying the "dummy" instruction.

Hello World

94DDDD294DDDD6369989829863690236496DDDD296DDDD6369989529
563690236496DDDD296DDDD636998982986369023216369989429463
6902364496DDDD296DDDD63699898298636902321636998972976369
0236492DDDD292DDDD63699898298636902321636998942946369023
6492DDDD292DDDD6369989029063690236495DDDD295DDDD63699897
29763690236496DDDD296DDDD6369989829863690232163699897297
63690236497DDDD297DDDD6369989229263690236496DDDD296DDDD6
36998982986369023216369989429463690236496DDDD296DDDD6369
989429463690236492DDDD292DDDD6369989129163690236491DDDD2
91DDDD6369989029063690236491DDDD291DDDD63699893293636902
364

Explainations here.

Cat halting on EOF

191290512906268064906912A

Truth machine

56226492621DA

Implementations

The original implementations from User:Palaiologos are available here.

User:Matthilde's reverse-engineering writeup and C99 implementation is available in this git repo.