xEec

From Esolang
Jump to navigation Jump to search

xEec is an esoteric programming language designed and implemented by Paulo Jorente in October, 2015.

Language details

xEec has a set of 9 instructions. Some of them work with parameters that specify its behavior. All instructions must be separated by white spaces. xEec is not case sensitive.

xEec operates on a single Stack of 64-bit wide unsigned integers. It has an internal flag (Carry Flag) that will be set every time an arithmetic operation overflows.

Semicolons are used to start a comment. Everything after a semicolon until the end of that line is a comment that gets ignored by xEec.

If xEec encounters a jump instruction but cannot find the matching label for this jump, the program will terminate.

From here on, let us assume that the right most item of a list is the top of the stack, consequently, that’s the value the next POP instruction will discard.
So, if we have the stack: [1,2,3] and we call POP, 3 will come out, leaving [1,2] behind.
The opposite is true for PUSH: same Stack: [1,2,3], PUSH 4, stack is now: [1,2,3,4].

xEec instructions set

Name Instruction Description
Push
h
Pushes a number or a char onto the stack h#9 pushes a 9, h$0 pushes 48(ASCII code for 0) and h? will push 1 if the Carry is set, 0 otherwise.
Pop
p
Discards the top of the stack.
Label
>
Creates a jump label. >lbl creates a label called lbl.
Input
i
Inputs a number or a char and place it on top of the stack. i# inputs a number and i$ inputs a char.
Output
o
Outputs the top of the stack as number or char. o# for numbers - o$ for chars. This instruction does not perform a pop.
Jump
j
Jumps to a label. jz will jump if top of the stack is zero, jn otherwise. jzlbl will jump to label lbl if top of the stack is zero. This instruction does not perform a pop.
Roll
r
Rolls the stack 1 position to the left. Before: [1,2,3] After [2,3,1].
Copy
to
Tail
t
Copies the top of the stack to its tail. Before: [1,2,3] After: [3,1,2,3]
Arithmetic
m
Performs one of the two possible arithmetic operations in xEec: ma: addition or ms: subtraction.
These instructions will pop the top two elements of the stack and push into it the result of that operation.

xEec Programming examples

Hello, World!

h#10 h$! h$d h$l h$r h$o h$W h#32 h$, 
h$o h$l h$l h$e h$H >o o$ p jno

Cat

>l    ; start loop
p     ; discards stack top - if the stack is empty, xEec just ignores the instruction
i$    ; input char( and pushes it )
o$    ; output char
p     ; pop char
h#10  ; push 10
o$    ; output 10 = new line
jnl   ; back to loop

Truth-machine

i# jzend >00 o# jn00 >end o# p

Fibonacci sequence

First 93 numbers

h#1 h#1 h#1 o# h#10 o$ p 
>f o# h#10 o$ p ma h? jnext p t jnf

99 bottles of beer

h#99 >0000 o# jn000_ >0000_ p o# jn0_00 >000_0 p jn00_0 >00_00 p h#1 r ms t h#1 ms p h? 
jz00100 p o# jn001_0 >01000 p jn0000 >00100 p o# jn00_10 >_0000 p o# jn0_100 >0_000 p o# 
jn01110_ >1 p jn0200_0 >10_010 jz~0 >00_0 h#0 h#32 h$, h$d h$n h$u h$o h$r h$a h#32 h$t 
h$i h#32 h$s h$s h$a h$p h#32 h$d h$n h$a h#32 h$n h$w h$o h$d h#32 h$e h$n h$o h#32 h$e 
h$k h$a h$T >lt o$ p jnlt jz00_00 >0200_0 h#0 h#10 h$. h$l h$l h$a h$w h#32 h$e h$h h$t 
h#32 h$n h$o h#32 h$r h$e h$e h$b h#32 h$f h$o h#32 h$s h$e h$l h$t h$t h$o h$b h#32 h$e 
h$r h$o h$m h#32 h$o h$n h#32 h$, h$d h$n h$u h$o h$r h$a h#32 h$t h$i h#32 h$s h$s h$a 
h$p h#32 h$d h$n h$a h#32 h$n h$w h$o h$d h#32 h$e h$n h$o h#32 h$e h$k h$a h$T >10_01 
o$ p jn10_01 jz10_010 >0_00 h#0 h#10 h$. h$r h$e h$e h$b h#32 h$f h$o h#32 h$s h$e h$l 
h$t h$t h$o h$b h#32 >2211 o$ p jn2211 jz000_0 >000_ h#0 h#32 h$, h$l h$l h$a h$w h#32 
h$e h$h h$t h#32 h$n h$o h#32 h$r h$e h$e h$b h#32 h$f h$o h#32 h$s h$e h$l h$t h$t h$o 
h$b h#32 >1122 o$ p jn1122 jz0000_ >001_0 h#0 h#10 h$. h$l h$l h$a h$w h#32 h$e h$h h$t 
h#32 h$n h$o h#32 h$r h$e h$e h$b h#32 h$f h$o h#32 h$s h$e h$l h$t h$t h$o h$b h#32 
>1111 o$ p jn1111 jz01000 >00_10 h#0 h#10 h$. h$l h$l h$a h$w h#32 h$e h$h h$t h#32 h$n 
h$o h#32 h$r h$e h$e h$b h#32 h$f h$o h#32 h$e h$l h$t h$t h$o h$b h#32 >2121 o$ p jn2121 
jz_0000 >0_100 h#0 h#32 h$, h$l h$l h$a h$w h#32 h$e h$h h$t h#32 h$n h$o h#32 h$r h$e 
h$e h$b h#32 h$f h$o h#32 h$e h$l h$t h$t h$o h$b h#32 >1331 o$ p jn1331 jz0_000 >01110_ 
h#0 h#10 h$. h$r h$e h$e h$b h#32 h$f h$o h#32 h$e h$l h$t h$t h$o h$b h#32 >1551 o$ p 
jn1551 jz1 >~0 h$. h$l h$l h$a h$w h#32 h$e h$h h$t h#32 h$n h$o h#32 h$r h$e h$e h$b 
h#32 h$f h$o h#32 h$s h$e h$l h$t h$t h$o h$b h#32 h$9 h$9 h#32 h$, h$e h$r h$o h$m h#32 
h$e h$m h$o h$s h#32 h$y h$u h$b h#32 h$d h$n h$a h#32 h$e h$r h$o h$t h$s h#32 h$e h$h 
h$t h#32 h$o h$t h#32 h$o h$G h#10 h$. h$r h$e h$e h$b h#32 h$f h$o h#32 h$s h$e h$l h$t 
h$t h$o h$b h#32 h$e h$r h$o h$m h#32 h$o h$n h#32 h$, h$l h$l h$a h$w h#32 h$e h$h h$t 
h#32 h$n h$o h#32 h$r h$e h$e h$b h#32 h$f h$o h#32 h$s h$e h$l h$t h$t h$o h$b h#32 h$e 
h$r h$o h$m h#32 h$o h$N >5115 o$ p jn5115

Odd or Even

>100 p i# jz-1 o# t h#1 ms jz2003 p >0110 h#2 r ms t h#1 ms p jz1002 h? jz2003 p 
jn0110 h#10 o$ p jn100 >2003 p p h#0 h#10 h$d h$d h$o h#32 h$s h$i h#32 jn0000 
>1002 p p h#0 h#10 h$n h$e h$v h$e h#32 h$s h$i h#32 >0000 o$ p jn0000 jz100

Multiplication

h#42		; multipilicand
h#121		; multiplier
h#1 r ms r t t r >0000 ma r h#1 
r ms jzout r r t jn0000 >out r o#

Division

h#0		; quotient
h#3		; divisor
h#319	        ; dividend
>0000 r r t r r ms h? jnx000
p r h#1 ma t p jze000 jn0000
>x000 p >e000 p p o#

Rot 47

h$! h$d h$e h$v h$l h$o h$v h$n h$i h#32 h$e h$B 
>1 t h#32 ms h? jz4 p p r t h#127 ms h? jn4 p p r t h$O 
ms p h? jz5 p h$P r ms h#33 ma jn2 >5 p r h#47 ma >2 o$ 
p jz3 jn1 >4 p p r jn2 

Minsky subtraction

h#91 h#120 >1 jz4 r h#1 r ms jn2 jz2 >2 r jz3 
r h#1 r ms r jn1 jz1 >3 r h#1 ma >4 o# h#10 o$

Computational class

xEec is Turing complete.
As you can see above, there is a translation of a Minsky machine.

External resources

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