2 trits, 3 trytes

From Esolang
Jump to navigation Jump to search

2 trits, 3 trytes is an assembly language invented by User:TheBigH that existed for months but he just didn't make an article on it. It is inspired by 2 Bits, 1 Byte.

Commands

Command (Trinary) Command (Disassembled) What it does
00 NOP Do nothing (a NOP)
01 ACT ACTion. Given value in memory, completely mix it up according to the following:

00 -> 12 -> 10 -> 20 -> 01 -> 22 -> 21 -> 02 -> 11 -> 00

02 CJM Conditional JuMp. Given two addresses, if the value in the first address is nonzero, jump to the second address.
10 JMP Given value in memory, JuMP to that instruction.
11 INC Given value in memory, INCrease given value (wraps)
12 DEC Given value in memory, DECrease given value (wraps)
20 TCO Given three addresses, Tritwise COnfusion** the first two addresses together and store the result in the third.
21 OUT Given a 2 trit number, OUTput the value of that tryte as a char*. If the number is more than 4, 5 gets subtracted from it.
22 TEM TErMinates the program.
*This uses a 4-trit version of ASCII. Here's a chart:
  012345678

0 ○░▒π∞↊↋×÷
1 ¬µ█/'"\?~
2 `!@#$%^&*
3 012345678
4 9.,:;=-_+
5 ()[]{}<>|
6 ▓ABCDEFGH
7 IJKLMNOPQ
8 RSTUVWXYZ

**Tritwise confusion uses this table (side is input 1 and top is input 2):
  012

0 212
1 022
2 011

The instruction pointer can wrap around, thus allowing more "complicated" programs. Since the memory is 2 trytes, you can represent the entire program with just 5 characters. The last 2 trits of the last character aren't used. For example:

!!!!!

becomes:

02010201020102010201

which, when disassembled, becomes:

CJM 0x1 0x2
ACT 0x2
ACT 0x2
ACT 0x2

Programs

Output any 2 characters

CD○??

where the ??? is replaced with the 2 characters. When disassembled, this becomes:

OUT 0x3
OUT 0x4
NOP
NOP
???

Infinite loop

○○○○○

Interpreters

https://snap.berkeley.edu/project?username=lionheart921&projectname=2%20trits%2c%203%20trytes by User:TheBigH

See also