6 trits, 243 trytes

From Esolang
Jump to navigation Jump to search

This is an esolang created by islptng. Unlike most of "x bits, y bytes", this esolang is serious.

Note: 1 tryte is 6 trits.

Syntax

This language uses the balanced ternary. The syntax is like a high-level language, because it has "if", "while", "break", etc. However, it has only a limited memory of 1,458 trits(and memory are wrapped at 729 i.e. 728+1=0), while program is stored in the memory.
Note that every instruction's length is a multiply of 6 trits.

Trits Character notation Meaning
0<address> get Read memory
t<address><value> set Write value to memory
1t<codes>1100 do ... end Code block
11t1<cond>10<codeblock> while ... then While loop
11tt<cond>10<codeblock> if ... then If block
110t00 halt halt
110t01 continue continue
110t0t break break
111tt0 inp Get a number from user.
111tt1<val> outp Output the value as signed number.
111t10 getch Get a character form user.
111t1t<val> putch Output the value as a character.
Commands below has 1 argument.
110t10 neg Tritwise NOT (1->t->1, 0->0)
110t11 rotu Tritwise Rotate Up (t->0->1->t)
110t1t rotd Tritwise Rotate Down (t->1->0->t)
110tt1 rise Tritwise Rise (t->0->1->1)
110ttt fall Tritwise Fall (1->0->t->t)
110tt0 sign Take its sign. Returns 000000, 111111 or tttttt
Commands below begins with 111. They have 2 arguments.
00t mod Modulo.
001 mul Multiplication
000 add Addition
0tt and Tritwise AND.
0t1 or Tritwise OR.
0t0 teql Tritwise Equal. 1 if two trits were equal, t otherwise.
01t shl Tritwise shift left.
011 shr Tritwise shift right.
010 rol Tritwise rotate left.
t00 eql Equality. 111111 if two arguments are the same, tttttt otherwise.
t11 div Division.
ttt abs Absolute value.
t0t lsi Less than. (Signed)
t01 lsu Less than. (Unsigned)

Examples

Hello World

Character:

while lsu get_p get_enddat then do putch do do p:data end end set_p add get_p get_const1 end halt
data: 72 101 108 108 111 44 32 87 111 114 108 100 33 enddat:const1:1

Ternary dump:

11t111 1t0100 01t000
100110 1t111t 1t1t1t
00011t 110011 00t001
t01110 000001 t00010
011100 110t00
; below is decimal
72 101 108 108 111 44 32 87 111 114 108 100 33 10 1