5 Bits, 20 Bytes

From Esolang
Jump to navigation Jump to search

5 Bits, 20 Bytes is an assembly language invented by User:None1 for a 5-bit CPU. It is inspired by 3 Bits, 3 Byte, which is inspired by 2 bits, 1 Byte. User:MihaiEso asked the author to invent the language. This language has all the commands in 3 Bits, 3 Bytes.

It has basic functionalities of normal programming languages, so it is not a joke.

Commands

Command (Binary) Command (Disassembled) What it does
00000 NOP Do nothing (a NOP)
00100 TEM TErMinate the program
01000 OUT Given a 5-bit value x after it, OUTput the x-th byte. (If x>=20, it does nothing)
01100 INP Given a 5-bit value x after it, INPut the x-th byte. (If x>=20, it does nothing)
10000 INC Given value in memory, INCrease given value (wraps)
10100 JMP JuMP. Jump (unconditionally) to address specified.
11000 CJM Conditional JuMp. Given two addresses, if the value in the first address is nonzero, jump to the second address.
11100 NEG NEGate given address, formally, if its value is x, let it be 7-x.
00001 ADD ADD the two addresses, stores result into second address.
00101 SUB SUBtract the two addresses, stores result into second address.
01001 MUL MULtiply the two addresses, stores result into second address.
01101 AND Bitwise AND the two addresses, stores result into second address.
10001 BOR Bitwise OR the two addresses, stores result into second address.
10101 XOR Bitwise XOR the two addresses, stores result into second address.
11001 INV Bitwise INVert address.
11101 PRN PRiNt the whole memory as characters.
00010 OUI OUtput the given address as Integer.
00110 INI INput the given address as Integer.
01010 CPY CoPY the first address to the second.
01110 CJZ Conditional Jump. Given two addresses, if the value in the first address is Zero, jump to the second address.
10010 OUB OUtput the given address as Binary.
10110 INI INput the given address as Binary.
11010 OUO OUtput the given address as Octal.
11110 INO INput the given address as Octal.
00011 OUX OUtput the given address as HeXadecimal.
00111 INX INput the given address as HeXadecimal.
01011 OUH OUtput the memory as Hex dump.
01111 LST Given 3 address, set the third to 1 if the value of the first is LeSs Than the value of the second, otherwise 0.
10011 LSE Given 3 address, set the third to 1 if the value of the first is LeSs than or Equal to the value of the second, otherwise 0.
10111 GTT Given 3 address, set the third to 1 if the value of the first is GreaTer Than the value of the second, otherwise 0.
11011 GTE Given 3 address, set the third to 1 if the value of the first is GreaTer than or Equal to the value of the second, otherwise 0.
11111 CST Output the memory as a C STyle string, starting from a given address.

The instruction pointer can wrap around, thus allowing more "complicated" programs.

Example programs

Quine (cheating)

������������������

The 's can be any character in extended or standard ASCII.

Disassembled:

PRN
TEM
... // Anything

Hexdump:

E9 3F ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??

Hello World

øˆHello, World!␀����

The is a null character, the 's can be any extended or standard ASCII character. The second character has an ASCII value of 0x88.

Disassembled:

CST 0b00010
TEM
...

Hexdump:

F8 88 48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 00 ?? ?? ?? ??

See also