Spleenmap

From Esolang
Jump to navigation Jump to search

Spleenmap is a 2D language designed by fr34k in 2009. It uses four instructions, but only one to control data.

Workflow

Spleenmap uses a 1 byte large memory pool. Bits are pushed to this pool and when it has reached 1 byte its ASCII equivalent will be outputted and the pool will be emptied.

Bits are pushed from the left side, as

Pool   Push #

0      1
10     2
110    3
0110   4

And so forth.

When executing a program in Spleenmap, an initial program counter position is set. The nearest instruction is then executed, then the next one and so on. Only horizontal and vertical traveling is allowed. Nor can instructions be positioned so that the program counter can take several routes, going from one specific position.

Instructional set

* Indicates the start of the program counter.
. NOP/If statement. Acts as a path for the program counter, or an if statement depending on how many instructions link to it.
? End of program. Indicates where the program should terminate.
# Comment indicator. Every character forth to a new-line succeeding this, is treated as a comment.
+

Only instruction used to manipulate data. Behaves differently, depending on which direction the program counter enters from:

LEFT Push 1 to the pool
RIGHT Push 0 to the pool
TOP If left-most bit in pool is 0, push 1 to pool, else push 0
BOTTOM If left-most bit in pool is 1, push 1 to pool, else push 0

Important notes: Entering this instruction from top/bottom when the memory pool is empty, will result in a program halt. Only after the pool has been filled with at least 1 bit they will function normally.

The NOP/If Instruction

The NOP/If instruction depends on how many instructions are linked to it, and in what direction they are linked and controls the direction of the program counter.

If only one instruction is linked to the NOP/If instruction, it performs a NOP and lets the program counter jump to the next linked instruction.

When two instructions are linked, it's important to remember, that since the . statement only performs two instructions, and there are three possible linking pairs, there is one linkage that will result in a program halt. Below follows instructions on how to use the . instruction, with two linked instructions.

Structure Operation
 +        +  
+.*  or  *.+ 
 *        *  
If the left-most bit in pool is 1, travel up.

If the left-most bit in pool is 0, travel right/left.

 *        *  
+.*  or  *.+ 
 +        +  
If the left-most bit in pool is 1, travel right/left.

If the left-most bit in pool is 0, travel down.

 +
*.+
 +
Will result in program halt.

Examples

Hello, World!

This is the Hello, World! program.

   .++  ...+...+...
 +++ +* .         +
++      ++       +.
.        +       +
.+       + +..+ ++
 ++ +++ .+ +  + +
  +.. + .  + .+ .++
      . ...+ +    +
    ++.      +. ++.
    +         . .
    .+       ++ ++
     +++     +   +++   ?++.
       +     +     +      .
       .     +   ++.     ++
      ++     ++. +  +++  +
      +        . +... ++ +
      .+   ++. .       +..
       +++ + +++
         ++.

Endless loop

In this example, no end of program has been determined. When Spleenmap reaches a dead-end, it simply bounces back, traveling in the opposite direction. This program outputs 'U' for eternity.

*.+.

Program halt

A program (also called a Spleenmap) can never have more than 1 instructions in its possible travel direction. For example, if the program counter is traveling left to right, a new instruction may only exist either on top, to the right, or below the current instruction. Below are examples of legal and illegal programs.

Legal    Legal    Illegal    Illegal

*+       *++      *+ +        +
 ++        +       ++++      *+
                              +

Computational Class

As there are only eight bits of storage, Spleenmap cannot be Turing-complete, or even as powerful as a push-down automaton. Its exact computational class is not known, but since there are no bounds given to the size of the program, it seems likely that Spleenmap is finite-automaton-complete.