SwapLoad

From Esolang
Jump to navigation Jump to search
SwapLoad
Designed by RainbowDash
Appeared in 2025
Memory system Counters
Computational class Category:Unknown computational class
Reference implementation Provided on the page.

SwapLoad is a minimalistic OISC that uses only a single instruction. The instruction can be described in pseudo-code as:

SWAP PTR $PTR
$PTR = CONSTANT

When this is presented in assembly form it takes this shape.

SWPLD 10
SWPLD 32
SWPLD 23

Or more simply

10 32 23

Memory Layout

In a SwapLoad environment, memory is organized as follows:

[ PTR | IP | Program ... | Editable memory ... ]

PTR points to the memory location to be modified. The initial value for this is set at zero and also accesses values with zero-indexing.
IP is the instruction pointer. The initial value for this is set at two, because that is where the program starts.
Program is the instructions that will run until IP hits the end of the program.
Editable memory is the remaining memory cells, which can be modified by the program.

Reference Implementation

program = [
    # Random values; purely for demonstration
    10,
    32,
    23,
]

memory = [0, 2] + program + [0]*300
while memory[1] < 2+len(program):    
    ip = memory[1]      # fetch IP
    value = memory[ip]  # fetch program value
    pointer = memory[0] # pointer in memory

    memory[0], memory[pointer] = memory[pointer], memory[0]
    memory[pointer] = value

    print(f"ADDR {pointer} is now set to {memory[pointer]}")

    memory[1] += 1

print(memory[:20]) # print first 20 memory cells

Computational Class

Currently, SwapLoad is not believed to be Turing Complete. While it can perform infinite loops and modify memory, creating conditionals or a truth machine has not been done yet under this OISC.