Jumpback

From Esolang
Jump to navigation Jump to search

Jumpback is an esoteric programming language with no forward jumps.

Instructions

MOV dst, src			Copy src to dst
ADD dst, src			Add src to dst
SUB dst, src			Subtract src from dst
ADDEQ dst, src, cmp		Add src to dst if src == cmp
ADDNE dst, src, cmp		Add src to dst if src != cmp
SUBEQ dst, src, cmp		Subtract src from dst if src == cmp
SUBNE dst, src, cmp		Subtract src from dst if src != cmp
NEG dst				dst = (-1) * dst
PSH src				Push src to value stack
POP dst				Pop to dst from value stack
LBL				Push IP to address stack
JEQ a, b			Jump if a == b
JNE a, b			Jump if a != b
JLE a, b			Jump if a < b
JGE a, b			Jump if a > g
SHOW a				Display a

Jumps pop the target from the address stack.

Addressing modes

$ - Immediate
# - Memory
@ - Memory indirect

i.e.

MOV #0, 1		Writes the number 1 to memory[0]
MOV #0, #1		memory[0] = memory[1]
MOV #0, @1		memory[0] = memory[memory[1]]
MOV @0, @1		memory[memory[0]] = memory[memory[1]]

Examples

MOV #0, 10
MOV #1, 0
LBL
SHOW #0
SUB #0, 1
JNE #0, #1

is a countdown from 10 to 0.

The following program prints the first ten Fibonacci numbers:

MOV #0, 0
MOV #1, 1
MOV #2, 2
SHOW #0
SHOW #1
LBL
PSH #1
ADD #1, #0
POP #0
SHOW #1
ADD #2, 1
JNE #2, 10

Interpreter

  • Common Lisp implementation of the Jumpback programming language.