LNUSP
LNUSP is a language with a two-dimensional data space and code space and 5 commands.
LNUSP is intended as an improved PATH with better orthogonality and fewer commands. Another noticeable difference is that LNUSP allows the memory pointer to move diagonally, as well as horizontally and vertically. It was created by User:Zzo38, and the name means Low-SNUSP.
Source code format
Source code is specified in an unusual way in LNUSP. Each line begins with a three-digit number specifying how many times the rest of the line should repeat. For example,
000 ;This example program #1 000 .INPUT .OUTPUT 001 @ 007 ++ 003 **
expands to produce the following code, when run:
@ ++ ++ ++ ++ ++ ++ ++ ** ** **
Command set
+ Increase current memory cell by 1, mod 256 * Move memory pointer in the direction the IP is traveling ? Turn 45 degrees left if current memory cell is nonzero ! Turn 45 degrees left if current memory cell is zero @ Save position and go north, or if there is already a position saved, go back to that position and delete the saved position, or if already going north, unconditionally turn 45 degrees right
. (dot) is specially guaranteed to not do anything. The program starts in the top left corner going southeast.
The behaviour of @
was ambiguous in the original specification – it did not specify whether the IP direction was saved as well, or only the position. The existing interpreters appear to assume the latter, but the existing programs to assume the former (which may imply that none of the programs were ever tested).
Subroutines
Going off the north side of the program results in a subroutine being executed, followed by the instruction pointer reversing direction. Which subroutine is executed depends on how far over the column is from the left. With the leftmost column counting as 1, the columns are
- 8 = Input
- 24 = Output
- 41 = Stop
Example
This example works like the UNIX cat, copying its input to its output until EOF is read.
000 1234567890123456789012345678901234567890123456789 000 .INPUT .OUTPUT .STOP 001 . . . . 001 .?......!!................? . 001 ?. .! ! . ? . 001 ? . .! ! . ? . 001 ?.!..@..!............@...? . 001 !.............................@
Computational class
LNUSP is Turing-complete because Reversible Bitfuck can be compiled into it. The basic idea is to represent the tape using alternate cells along a single horizontal line in memory, using 128 as the value of a set bit. Then the commands compile as follows (with the IP entering at the .
at the left, going east):
(body)
!! !........! !! ! ! ! ! . . . . . ! ! . ....!.!..body..!.!.... . . ! ! !..............!
- The red rows can be duplicated to give more vertical space for the body, and likewise the red columns to give more horizontal space.
*
- 128
+
commands >
*
<
?!.*!? ?! !? ?! !? .. .. .... .. ...!??!...
In order to start the program, draw a trail of .
to the row of the bottom and use !
to turn. At the end of the program, four !?
can be used to turn the IP to be going left on the top row (in the same style as with the implementation of <
, and then an @
in the halting column causes the program to halt cleanly. (It is also possible to prove LNUSP to be Turing-complete without the @
command, via sending the IP round a small loop at the end of the program.)