SwapLoad
One instruction. Swap the pointer with what it points at, then load a constant there.
RainbowDash, 2025 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
RainbowDash made SwapLoad in 2025. It is a one instruction set computer whose single instruction does two things. It swaps the pointer cell with the cell the pointer names, and then writes the instruction's constant into that cell. A program is just the list of constants.
Read the story
The pointer and the instruction pointer live in memory too, in cells 0 and 1. So an instruction that points at cell 1 moves the instruction pointer, and the program can jump. The specification says nobody has yet built a conditional or a truth machine from it.
The machine
Memory is laid out as [PTR, IP, program..., 300 zeros]. PTR starts at 0 and IP at 2, the first number of the program.
| Step | Does |
|---|---|
| value | The number at IP |
| swap | Cell 0 and the cell PTR names change places |
| load | That cell becomes the value |
| next | IP goes up by 1 |
The run stops when IP passes the end of the program. The reference implementation prints a line for every step and then the first 20 cells, and this implementation prints the same.
Example
The demonstration program.
The demonstration program. The second instruction moves the pointer's old value 10 into cell 10 and then loads 32 there.
The assembly form SWPLD 10 on three lines is the same program.
Patterns it teaches
- One instruction: a single swap and load.
- Self-modifying code: the program, the pointer and the instruction pointer share one memory.
Further
See also
OISC
Self-modifying
Write your own in Run Convert a program from SwapLoad
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: swapload.
Command line
shib run swapload -e '10 32 23'shib manual swaploadSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/swapload.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org