0815

From Esolang
Jump to navigation Jump to search

0815 is an esoteric programming language designed and implemented between December 2012 and January 2013 by Paulo Jorente.

Language details

0815 is based around a queue and 3 registers. It only understands hexadecimal, so every numeric input and output is in hexadecimal. Everything that is not an instruction is a comment.

Registers

0815 has 3 signed 64-bit wide integer registers: X, Y, and Z. All three are initialized with 0. X is a write only register, and Z is a read only register. Y is a helper register unaccessible to the programmer.

Parameters

Some 0815 instructions need parameters. All parameters must be surrounded by colons, e.g. :3c:.

Labels are also considered parameters; therefore they also need the surrounding colons.

If a parameter is needed but none is found, the instruction will be ignored. No error message will display.

Jumps

In 0815, you'll find two kinds of jumps: if Zero (#) or if not Zero (^). Jumps' labels can contain any character, except the language reserved symbols, e.g. :_loop: or :34:.

If the label a jump is pointed to is not found, the program terminates.

New lines

Either ASCII 10 or 13 will be interpreted as a newline.

Instructions

Name Instruction Description
Move
<
<:2: will move 2 to register X
(parameter is mandatory)
Swap
x or X
swaps register X and Y
Label
}
}:_loop: this creates a label called _loop
(parameter is mandatory)
Input
number
|
inputs a signed 64 bit integer and stores it into X
(hexadecimal base)
Input
ASCII
!
inputs an ASCII char and stores it into X
Print
number
%
prints a signed 64 bit integer stored in Z
(hexadecimal base)
Print
ASCII
$
prints an ASCII char stored in Z
Roll
registers
left
~
rolls all registers to the left: X <- Y <- Z
after roll: X = Y, Y = Z and Z = X
Roll
registers
right
=
rolls all registers to the right: X -> Y -> Z
after roll: X = Z, Y = X and Z = Y
Jump
if not
zero
^
^:_loop: jumps to label _loop if Z is not 0
(parameter is mandatory)
Jump
if
zero
#
#:_loop: jumps to label _loop if Z is 0
(parameter is mandatory)

Queue instructions

Name Instruction Description
Clear
?
clears the queue
Enqueue
>
enqueues the number stored in Z (append to back)
Dequeue
{
dequeues a number and stores it into X (pop front)
Roll
queue
left
@
rolls the queue to the left: the first value becomes the last, the second will be first and so on. If no parameter is found, the queue will be rolled once, otherwise it will be rolled parameter times. e.g. @:a: rolls the queue ten times to the left.
Roll
queue
right
&
the same as @, except the roll will go to the right:
the last will be the first, the first will be the second and so on.

Arithmetic instructions

Name Instruction Description
Add
+
Z = X + Y
Subtract
-
Z = X - Y
Multiply
*
Z = X * Y
Divide
/
Z = X / Y
Y = rest

0815 Programming examples

Hello, World!

 <:48:x<:65:=<:6C:$=$=$$~<:03:+$~<:ffffffffffffffbd:+$<:ffffffffffffffb1:+$<:57:~$~<:18:x+$~<:03:+$~<:06:x-$x<:0e:x-$=x<:43:x-$

Cat

}:_t:!~$^:_t:

Truth-machine

|~}:i:%^:i:

Odd or Even

}:s:|=<:2:x~#:e:=/~%~<:20:~$=<:73:x<:69:~$~$~<:20:~$=^:o:<:65:
x<:76:=$=$~$<:6E:~$<:a:~$^:s:}:o:<:6F:x<:64:x~$~$$<:a:~$^:s:

Fibonacci sequence (0 - a94fad42221f2702h)

%<:0D:>~$<:01:~%>=<:a94fad42221f2702:>~>}:_s:{x{={~$x+%{=>~>x~-x<:0D:~>~>~^:_s:?

99 bottles of beer (63h bottles of beer)

<:63:x<:20:=<:62:>=>=><:6F:x<:74:=<:6C:>=>>=><:65:x<:73:=<:20:>=>=><:6F:x<:66:=<:20:>=>=>
<:62:x<:65:=<:72:>=>>=><:20:x<:6F:=<:6E:>=>=><:20:x<:74:=<:68:>=>=><:65:x<:20:=<:77:>=>=>
<:61:x<:6C:=>=>><:54:x<:61:=<:6B:>=>=><:65:x<:20:=<:6F:>=>=><:6E:x<:65:=<:20:>=>=><:64:x
<:6F:=<:77:>=>=><:6E:x<:20:=<:61:>=>=><:6E:x<:64:=<:20:>=>=><:70:x<:61:=<:73:>=>=>><:20:x
<:69:=<:74:>=>=><:20:x<:61:=<:72:>=>=><:6F:x<:75:=<:6E:>=>=><:64:~>}:_start:{~%><:1c:~
}:_99:~{~$>=<:01:x-^:_99:<:0D:~$@:20:{~%><:10:~}:_98:~{~$>=<:01:x-^:_98:<:0D:~$@:c:<:20:~
}:_97:~{~$>=<:01:x-^:_97:<:0D:~${x<:01:x->&==<:01:-#:_322:{~%><:1c:~}:_96:~{~$>=<:01:x-
^:_96:<:d:~$$@:20:{~>&^:_start:}:_90:?<:4E:x<:6F:=<:20:>=>=><:6D:x<:6F:=<:72:>=>=><:65:x
<:20:=<:62:>=>=><:6F:x<:74:=<:6C:>=>>=><:65:x<:73:=<:20:>=>=><:6F:x<:66:=<:20:>=>=><:62:x
<:65:=<:72:>=>>=><:20:x<:6F:=<:6E:>=>=><:20:x<:74:=<:68:>=>=><:65:x<:20:=<:77:>=>=><:61:x
<:6C:=>=>><:02:~}:_70:><:23:~}:_80:~{~$>=<:01:x-^:_80:{~<:01:=-#:_60:<:0D:~$$=^:_70:}:_60:
<:0D:~$<:17:~}:_81:~{~$=<:01:x-^:_81:<:0D:~$?<:47:x<:6F:=<:20:>=>=><:74:x<:6F:=<:20:>=>=>
<:74:x<:68:=<:65:>=>=><:20:x<:73:=<:74:>=>=><:6F:x<:72:=<:65:>=>=><:20:x<:61:=<:6E:>=>=>
<:64:x<:20:=<:62:>=>=><:75:x<:79:=<:20:>=>=><:73:x<:6F:=<:6D:>=>=><:65:x<:20:=<:6D:>=>=>
<:6F:x<:72:=<:65:>=>=><:21:~}:_18:~{~$=<:01:x-^:_18:<:0D:~$<:63:x<:20:=<:62:>=>=><:6F:x
<:74:=<:6C:>=>>=><:65:x<:73:=<:20:>=>=><:6F:x<:66:=<:20:>=>=><:62:x<:65:=<:72:>=>>=><:20:
x<:6F:=<:6E:>=>=><:20:x<:74:=<:68:>=>=><:65:x<:20:=<:77:>=>=><:61:x<:6C:=>=>>{~%<:1c:~
}:_21:~{~$=<:01:x-^:_21:<:0D:~$^:end:}:_322:?<:01:x<:20:=<:62:>=>=><:6F:x<:74:=<:6C:>=>>=
><:65:x<:20:=<:6F:>=>=><:66:x<:20:=>=><:62:x<:65:=<:72:>=>>=><:20:x<:6F:=<:6E:>=>=><:20:x
<:74:=<:68:>=>=><:65:x<:20:=<:77:>=>=><:61:x<:6C:=>=>><:54:x<:61:=<:6B:>=>=><:65:x<:20:=
<:6F:>=>=><:6E:x<:65:=<:20:>=>=><:64:x<:6F:=<:77:>=>=><:6E:x<:20:=<:61:>=>=><:6E:x<:64:=
<:20:>=>=><:70:x<:61:=<:73:>=>=>><:20:x<:69:=<:74:>=>=><:20:x<:61:=<:72:>=>=><:6F:x<:75:=
<:6E:>=>=><:64:~>{~%><:1b:~}:_299:~{~$>=<:01:x-^:_299:<:0D:~$$@:20:{~%><:1b:~}:_298:~{~$>
=<:01:x-^:_298:<:0D:~$@:20:{~%<:f:~}:_297:~{~$>=<:01:x-^:_297:<:0D:~$@:c:<:20:~}:_296:~{~
$>=<:01:x-^:_296:<:0D:~${x<:01:x->&==<:01:-^:_90:

Computational class

Using labels as states, and keeping track of two registers as stacks in the queue, one can easily translate a Minsky machine into a 0815 program(this requires that the registers are unbounded):

inc r1 S     <:1:~>&      <:0:~#:S:
inc r2 S     <:1:~>       <:0:~#:S:
dec r1 Z S   {~>& #:Z:  { <:0:~#:S:
dec r2 Z S   &{~> #:Z: &{ <:0:~#:S:

Therefore, 0815 is Turing complete.

External resources

  • 0815 page – features specs (again), programs and an interpreter.