From Esolang
Jump to navigation Jump to search

UnAsm is a language created by User:Normalcat, made as a joke to see how fast they could make a readable esolang. It is quite simple, while also being much more difficult to write practical programs than many other esoteric programming languages


The syntax in UnAsm is purposely extremely simple, spacing does not matter, as long as each command is separated via a newline or semicolon. UnAsm uses two registers to work with data, which can be saved/loaded using saveVars & loadVars. Almost all commands have a version for the first and second register. For conservation of length the r1 versions will only be shown, but the r2 versions do exist. This does not include out and outc, which only print the data from register 1.

The commands are as follows:

Command Description
r1 Sets the value of register 1 to the value provided.
r1+ Adds 1 to register 1.
r1- Removes 1 from register 1.
r1* Multiplies register 1 by register 2.
r1/ Divides register 1 by register 2.
r1= Sets register 1 to 0.
r1# Sets register 1 to a random integer between 0 (inclusive) and 256 (exclusive).
r1r2 Sets register 1 to the value of register 2, applies the other way aswell.
lbl Creates a label to jump to, with the name provided, note that this is interpreted so you cannot jump to later labels unless they have already ran and you have jumped back.
jmp Jumps to a label of the given name.
rjmp Jumps to a completely random line, including jumping to the line that ran it.
quit Ends the program.
src Prints the source code of the interpreter.
out Outputs register 1's value.
outc Outputs register 1's value as an ASCII character, however this may change depending on the interpreter.
swap Sets register 1 to register 2's value, and register 2 to register 1's value.
cmp Runs the next line only if register 1 is larger than register 2, otherwise it will skip the next line and move on. If r1/r2 aren't numbers, this should be treated as a nop.
saveVars Saves r1 & r2 to an in-memory slot args[0]
loadVars Loads r1 & r2 from an in-memory slot args[0]
jseval Evaluates the arguments passed using the JS eval function & puts their return value in the r1 register. Note that this may not be available in non-JS interpereters & some may require you to specify an option to enable this functionality

Commands/Instructions that aren't known about should be ignored.

Code examples

A simple hello world program,

r1 72; outc
r1 101; outc
r1 108; outc; outc
r1 111; outc
r1 32; outc
r1 87; outc
r1 111; outc
r1 114 ;outc
r1 108; outc
r1 100; outc
r1 33; outc

A program to count up starting at 0, printing newlines between each number.

r2 10
lbl Loop
jmp Loop


Unasm's original interpreter (written in JavaScript), by User:Normalcat can be found at it's Github Page

A typescript recode of said interpreter, written by User:MokiyCodes, can be found in 3 forms; a library, a web-demo & a CLI. Note it includes some non-official instructions as found here