Mineso

From Esolang
Jump to navigation Jump to search

Mineso is a turing-complete[citation needed] I can convert some BF to Mineso, but I don't know enough BF to convert anything programming language made by User:DeadlyFugu. It uses tape memory, which starts at position 0 and, if on a Turing machine, could go on for infinity. However, it'd be impracticle since Mineso uses unary, with the only number it has being '1'. Every operation in Mineso requires a number after it, having no 1's after it would be treated as a zero.

Language overview

Like BF, Mineso uses an array of memory cells, with a each set to zero by default and a pointer. You are expected to set the pointer on program start, so what the pointer is by default is up to the implementation.

Certain memory cells don't act as you would expect in BF. Cells 0,1,2,3,4,6,9,10,11 will all do something other then just store a value.

Assuming n is the value you are sending to the cell,

Cell Description
0 Goto the nth command in. This cell will always be the value of the current instruction (Hence, an implementation can't have more cells then the maximum a cell can go)
1 Add n to the existing value, and store in cell.
2 Subtract n from the existing value, and store in cell.
3 Multiply n by the existing value, and store in cell.
4 Divide the existing value by n, and store in cell.
6 Prints sent value using ASCII to stdout (It is not followed by a newline), and store in cell.
9 Bit-shift left, then store in cell
10 Bit-shift right, then store in cell
11 Prints sent value as a number to stdout, and store in cell.

The advantages of working this way is that one can easily add in a new mathematical operation or something, without the need to add in more commands. It also allows implementations to add in support for all sorts of crazy I/O, library access and whatnot, without the need to fork the language and add in new commands.

The value in the active cell can be modified and moved around using commands. Every command requires a unary number after it (With no 1's after it meaning a 0).

Assuming n is the tailing number:

Command Description
- Set the pointer to the cell n.
< Put n into the active cell, adhering with the cell's 'rules'.
> Put the active cells value into cell n, adhering with the cell's 'rules'.
= Set the cell to n, ignoring the cell's 'rules'.
? Set the cell to 1 or 0, depending on the result of a logical operation with the active cell and the 5th cell. n is the operation. 0 is 'Is the same as' (Or '=='), 1 is 'Less than' (Or '<'), 2 is 'More than' (Or '>'), 3 is 'Invert' (Or '!'). 3 doesn't care about the data in cell 5, it just inverts the active cells data (So ?1?111 is 'More than or equals', ?11?111 is 'Less than or equals')
[ If the active cell's value is non-zero, jump forwards n+1 commands.
] If the active cell's value is non-zero, jump backwards n+1 commands.
@ Pull the value from position n into the active cell, ignoring the cell's 'rules'.

Any symbols that are not in the above list or a 1 are ignored (So '<C a,1R' is equivalent to '<1').

Examples

Hello, World!

This should print 'Hello World!' to the screen (Without a newline)

-1
<111111111111111111111111111111111111111111111111111111111111111111111111
>111111
<11111111111111111111111111111
>111111
<1111111
>111111
>111111
<111
>111111
=11111111111111111111111111111111
>111111
<1111111111111111111111111111111111111111111111111111111
>111111
<111111111111111111111111
>111111
<111
>111111
>11
-11
@111111
<111111
>111111
<11111111
>111111
=111111111111111111111111111111111
>111111

To the power of

Replace A with a unary number, and B with a unary number. It then prints A to the power of B.

-111            # Change to multiplication cell at position three
=1              # Set multiplication cell to one

-11111          # Change to fifth cell
=A              # Receive exponentiation base A

[11             # Proceed as usual if A does not equal zero
=1              # Otherwise set fifth cell to one for subsequent
[11111111111    # skipping to end of program

-11             # Change to subtraction cell for setting exponent B
=B              # Store exponent B in the subtraction cell

[11             # Proceed as usual if B does not equal zero
=1              # Otherwise set subtraction cell to one for subsequent
[111111         # skipping to end of program

-11111          # Change to fifth cell for multiplying with multiplication cell
>111            # Multiply multiplication cell by A via fifth cell

-11             # Change to subtraction cell for subsequent deduction and back jump test
<1              # Decrement B value in its agency as a jump counter
]111            # Jump back if necessary for repeated multiplication
-111            # Switch to multiplication cell which contains the power

-111            # Change to multiplication cell at position three for pending printing
>11111111111    # Output multiplication cell with its exponentation result

Counts down

] is very useful for loops, this is a good example.

-11=111111<1>11111111111]1

Powers of two

This program outputs the powers of two (2), with the exponents commorant in the closed interval [0, 7]:

-11111
=11111111
-11
@11111
-11111
=1
-111111111
@11111
-111111111
>11111111111
<1
-11
<1
]1111

External resources

Implementations

Mineso interpreter (dead link) by User:DeadlyFugu. The interpreter uses 8-bit cells with 256 cells in total. One could easily rewrite the source code (It's GPL'd) to have bigger/more cells. Also, the Window's .exe's are outdated, and the debug info probably doesn't make any sense to anyone other then him. Then again, it is an esoteric programming language, no?

Common Lisp implementation of the Mineso programming language.