COPYCAT
One instruction. It copies a byte, and the program counter is just another byte to copy into.
ACanOfDrPepper, 2026 · Turing complete: no · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
ACanOfDrPepper made COPYCAT in 2026. It is a one instruction computer with a 16-bit address space. Every instruction is four bytes, a source address and a destination address, and copies one byte. There is no opcode, because there is only one thing to do.
Read the story
Jumps, input, output and halting are all addresses. The program counter sits at 0x0000 and 0x0001, so a jump is a copy into it. Reading 0x0002 reads a byte, writing it prints one, and writing 0x0003 halts. With 64 KiB of memory and nothing more, the specification counts it as a finite state machine.
The machine
| Address | Reading gives | Writing does |
|---|---|---|
0x0000 0x0001 | The address of this instruction | Jump there next |
0x0002 | One byte of input | Print the byte |
0x0003 | 0 | Halt |
0x0004 and up | The program, then free memory | Store the byte |
The instruction 34 12 78 56 copies the byte at 0x1234 to 0x5678, both addresses low byte first. After every copy that is not a jump the counter moves on by 4.
Example
This program copies the two bytes after its halt to the output.
This program copies the two bytes after its halt to the output.
The truth machine copies the input byte into the low byte of the counter, so 0 jumps to 0x30 and 1 to 0x31. At 0x30 it prints the 0 and halts. At 0x31 it reads the same bytes one place out of step. The first of those copies the counter's own low byte, 0x31, over the program's first byte, and further on a loop prints that byte for ever.
The cat rewrites its second instruction as it runs. It stores each byte it reads as the high byte of that instruction's destination, so a harmless copy becomes a write to 0x0003 once the byte read is 0. That 0 is printed before the halt, so the cat ends its output with a 0 byte.
Patterns it teaches
- One instruction: copy is the whole instruction set; the addresses do the rest.
- Self-modifying code: the cat stops by rewriting its own instruction.
Further
See also
OISC
Self-modifying
Write your own in Run Convert a program from COPYCAT
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: copycat.
Command line
shib run copycat -e '00 00 FF FD
FF FF 03 FF
02 00 FE FF
FE FF 02 00
FE FF 0B 00
FF FD 00 00' --input 'cat'shib manual copycatSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/copycat.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org