JUMP

From Esolang
Jump to: navigation, search

JUMP is a three command programming language by User:EzoLang with binary I/O. Commands are GOTO x, IF x THEN GOTO y ELSE GOTO z and OUTPUT x. If a program jumps to a non-existing destination the program stops.


Syntax

0 OUTPUT 0 IF 1 THEN GOTO 4 ELSE GOTO 1
1 OUTPUT 1 IF 0 THEN GOTO 0 ELSE GOTO 2
2 IF 1 THEN GOTO 1 ELSE GOTO 3
3 GOTO 0

The possible line forms are

line number IF 1 or 0 THEN GOTO line number ELSE GOTO line number

or

line number OUTPUT 1 or 0 IF 1 or 0 THEN GOTO line number ELSE GOTO line number

or

line number GOTO line number

or

line number OUTPUT 1 or 0 GOTO line number

IF x THEN GOTO y ELSE GOTO z means: if input is x then jump to y, if it isn't jump to z. OUTPUT x outputs the 1 bit binary number x. GOTO x means jump to x.

Binary form

0 OUTPUT 0 IF 1 THEN GOTO 2 ELSE GOTO 1
1 IF 0 THEN GOTO 0 ELSE GOTO 2
2 OUTPUT 1 GOTO 0

becomes

1011010100100000000110001100

which can be divided into four blocks (because 2 bits is the minimum binary number length to store numbers 0-2. The last block is this time 0001100).

1011010
1001000
0000011
0001100

Every block can be divided into five pieces

A B  C  D E
1 01 10 1 0
1 00 10 0 0
0 00 00 1 1
0 00 11 0 0

D is 1 if the line used OUTPUT. E is the number to output. A is 0 if the line used GOTO and 1 if it used IF THEN GOTO ELSE GOTO. B is the destination if input is 0 or if A is 0. C is the destination if input is 1. If A is 0 and C is all ones program halts.

Examples

CAT

0 IF 0 THEN GOTO 1 ELSE GOTO 2
1 OUTPUT 0 GOTO 0
2 OUTPUT 1 GOTO 0

In binary form

1011000000001000000110001100

2 Bit counter

0 OUTPUT 0 GOTO 1
1 OUTPUT 0 GOTO 2
2 OUTPUT 0 GOTO 3
3 OUTPUT 1 GOTO 4
4 OUTPUT 1 GOTO 5
5 OUTPUT 0 GOTO 6
6 OUTPUT 1 GOTO 7
7 OUTPUT 1 GOTO 0

In binary form

000100010001000010001100010010000011010100011011000010011100011000000011

Truth-machine

0 IF 0 THEN GOTO 2 ELSE GOTO 1
1 OUTPUT 1 GOTO 1
2 OUTPUT 0 GOTO 3

In binary form

110010000100110110010

Computational class

JUMP is not turing complete. Every JUMP program can be translated to a DFA.