Jumper

From Esolang
Jump to navigation Jump to search

Jumper is an assembly-like language made by Somnium for codegolf.

RAM

Jumper is a lot like Brainfuck, though the tape is called RAM and it has some different properties:

  • It operates with random-access-memory with bytes as cells. RAM is zero indexed and initially filled with zeros.
  • When trying access cells with negative indexes error should be displayed and program terminated.
  • When trying read at larger index than last, zero should be returned.
  • When trying write at larger index than last, RAM should be increased to multiple of 1024 and new cells filled with zeros (technically you can increase RAM not to multiple of 1024, reason was performance boost, so if it costs you a lot of characters you can do it not to multiple of 1024).

Program also has pointer to cell in RAM which initially is zero

  • When program starts executing a prompt for input string should be displayed (or take input from command line arguments, it's up to you). Input string should not contain null character (zero byte). Then input string is written to RAM starting at zero index.
  • When program ends executing a box with program output is displayed - contents of RAM from zero index to first zero byte excluding.

Commands

Jumper consists of commands (unary operators-prefixes) and their arguments. Commands and arguments may be delimited with spaces or new lines but not necessary. However spaces inside arguments are invalid, for example, # 2 = 4 is valid, but # 2 = 4 4 is not. Programs can have comments between (). Comments can't be nested - for example, in (abc(def)ghi) comment is (abc(def). Comments can be placed anywhere.

  • #123 sets RAM pointer to 123 (any positive decimal integer or zero).
  • >123 increments RAM pointer by 123 (any positive decimal integer).
  • <123 decrements RAM pointer by 123 (any positive decimal integer).
  • =123 writes 123 (any unsigned 8-bit decimal integer) in current cell.
  • +123 adds 123 (any unsigned 8-bit decimal integer) to current cell (modulo 256).
  • -123 subtracts 123 (any unsigned 8-bit decimal integer) from current cell (modulo 256).
  • :123 - “goto” - goes to command number 123 (first is 0). You can control flow of your program only with goto’s - it has to jump - that’s why this language is called Jumper.

If argument is missing, it is 1 for ><+- commands or 0 for #=: commands.

Also, there is command modifier - ? (prefix to command), it executes next command only if current cell is not zero, else skips that command. Can be applied to any command. For example, `?:17` - goes to command 17 if current cell is not zero.

Examples

(prints "Hello world!" regardless of input)
=72>=101>=108>=108>=111>=32>=119>=111>=114>=108>=100>=33>=
(appends "!" to the end of input string)
?:2 :4 >1 :0 =33 >1 =0

External resources