CARP

From Esolang
Jump to navigation Jump to search

CARP stands for 'Canonian Analog Redstone Processor.' It is an esoteric programming language created by User:TheCanon2.

As the name implies, CARP is designed as a machine code for a hexadecimal Minecraft redstone computer.

Commands

CARP 1

CARP has fifteen 1-nibble (4-bit) registers with addresses 1 to 15. All CARP commands accept and require 2 operands, a register R and a line C. CARP has five commands.

Opcode Symbol Action
1 INC If the value at R is 15, goto C. Else, increment and move 1 line forward.
2 DEC If the value at R is 0, goto C. Else, decrement and move 1 line forward.
3 WIPE Set the value at R to 0 and move 1 line forward
4 OUT Output the value at R and move 1 line forward.
5 IN Accept an input and write it to R and move 1 line forward

Line numbers start at 1 and increment by 1 for each line in the program. Halting is done by forcing a jump to line 0, for the physical decoder only activates when it receives a non-zero signal strength.

Examples

Truth machine

IN 1 (2)
DEC 1 6
INC 1 (4)
OUT 1 (4)
DEC 0 4 # All undefined values are 0.
DEC 0 0

For clarity, numbers not necessary to run the program are in parentheses.

Computational class

CARP can simulate a two-register Minsky machine.

INC 1 2 Increment register 1

DEC 1 3 Decrement register 1 and jump to instruction 2 unless it is zero in which jump to instruction 3.

However, CARP is a bounded storage machine due to its limited cell width.