esolang

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

Expected: ADDR 0 is now set to 10 ADDR 10 is now set to 32 ADDR 0 is now set to 23 [23, 5, 10, 32, 23, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0]

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.

StepDoes
valueThe number at IP
swapCell 0 and the cell PTR names change places
loadThat cell becomes the value
nextIP 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

Further

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 swapload

Source

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