xEec
Nine instructions, one stack of 64-bit unsigned numbers, a carry flag and labels to jump to.
Paulo Jorente, 2015 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 5 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Paulo Jorente designed and implemented xEec in October 2015. It reads like a tiny assembly language. There is no multiplication, no comparison and no way to look below the top of the stack, so programs roll the stack round to reach their numbers and subtract to compare them. The carry flag says when a subtraction went below zero.
The machine
One stack. Words are separated by whitespace and ; starts a comment.
| Word | Does |
|---|---|
h#9 h$a h? | Push 9, push the code of a, push the carry (1 or 0) |
p | Pop |
>name | A label |
i# i$ | Read a number or a character |
o# o$ | Write the top as a number or a character, without popping |
jzname jnname | Jump to the label if the top is 0, or if it is not; no pop |
r | Roll left: [1,2,3] becomes [2,3,1] |
t | Copy the top to the bottom |
ma ms | Pop the top a and the next b, push a + b or a − b |
Numbers wrap at 2 to the 64th, and ma and ms set the carry exactly when they wrap. A jump to a label that does not exist ends the program, which is how most programs stop.
Example
Hello World pushes the text backwards, then prints and pops until the 10 at the bottom is gone and jno…
Hello World pushes the text backwards, then prints and pops until the 10 at the bottom is gone and jno finds an empty stack. The second program multiplies 42 by 121 by adding 121 to itself 41 times. The third divides 319 by 3. It subtracts 3 until the carry shows the subtraction went below zero.
Further
Ideas it shows
See also
Stack-based
Write your own in Run Convert a program from xEec
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: xeec.
Command line
shib run xeec -e 'i# jzend >00 o# jn00 >end o# p' --input '0'shib manual xeecSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/xeec.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org