esolang

XOR

Every value lives in a declared variable, and the only branch jumps a number of commands.

Brain Boy 53, 2024 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 9 known programs · Test method

Run it

Expected: Hello, World!

The idea

Brain Boy 53 made XOR in 2024, after FALSE. The specification says that as false is its author's favourite truth value, XOR is the favourite logic gate. Only a set command takes a number or a string. A value goes into a declared variable first, and every other command names variables.

Read the story

A program is commands separated by spaces, and a string cannot hold a space. So the Hello World keeps its space in a character variable, as the code 32.

The machine

CommandDoes
i"x" c"x" s"x"Declare an integer, a character or a string x
I.x.5 C.x.65 S.x.textSet x
p_i_x u_i_xPrint x or read it; the letter in the middle is its type, i, c or s
a.x.y.zSet z to x plus y
t.x.ySet y to 1 if x is 0, else to 0
f$a$b$c$dIf a equals b move c + 1 commands on, else d + 1
eEnd

In place of a, b subtracts, m multiplies, v divides, d takes the remainder, and n, r and x are the bitwise and, or and xor. A move of 1 is the next command and a move of 0 stays put, which is the infinite loop. A negative move goes back.

The specification links an interpreter in Python on replit. Where the specification is silent this implementation takes the plainest reading. Division rounds down, a number is read from one line, and print adds no line feed.

Example

The equality checker from the specification.
Expected: 42
Expected: 1

The equality checker from the specification. With c at 0 and d at 1, equal inputs make the first f move 1 to the print of ==, and the second move 2, past the print of != to the end. Different inputs make both jumps go the other way.

Expected: !=

Patterns it teaches

Further

Also in Turing tarpits

Write your own in Run Convert a program from XOR

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: xor.

Command line

shib run xor -e 's"t" u_s_t p_s_t' --input 'meow'
shib manual xor

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/xor.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org