Rotary

General information
Rotary is an esoteric programming language created by User:InputUsername in September 2014. Rotary was made to be confusing, not usable. It was loosely based on BrainFuck, sharing some of its features like a data tape and single-character instructions. However, there are many more interesting differences than similarities.

First of all, programs are restricted to a specific format: a circle (hence the name). A typical Rotary program looks like this:

###x## ###     ###  #            #  #            #   ###      ###      ###### (where '#' and 'x' represent any valid Rotary instruction)

Execution starts at the position indicated with an x, and goes clockwise. Every program runs until the last instruction of a circle has been executed.

A program can contain multiple circles. Every circle must be separated by a blank line, like this:

###     ###     ######     ######  ###      ###

The currently executing circle can be changed using built-in instructions.

As said before, the main form of memory is a tape of unsigned bytes (values 0-255) and a stack, also containing unsigned bytes.

Another feature is the fact that there are independent input and output pointers. Any instruction that puts input onto the tape will put this input in the cell under the input pointer (called INPP from now on). Likewise, any output instruction will use the data in the cell pointed to by the output instruction (OUTP). The INPP and OUTP will start at the first cell. There are instructions to manipulate the I/O pointers.

If a program file contains characters that are not instructions, the interpreter will show an error and halt. This makes it impossible to comment your code; however, behaviour might change in the future.

Any piece of code that is not formatted as a circle will be ignored.

Similar to BrainFuck
As can be seen, the [ and ] instructions are missing, as they can, with some effort, be emulated using other instructions.

Rotary instructions
*   Won't do anything if there's only one circle. Will wrap the CP. **  These only work if they're not the last instruction, of course. *** Won't do anything if the stack is empty.

More information on program flow
Rotary programs consist of circles. The instruction pointer will move clockwise from the starting point to the end of a circle. If the end of a circle is reached, the program exits, even if there are circles before or after the current circle. There are instructions to manipulate the circle pointer (which indicates the currently executing circle). Therefore it is possible to make infinite loops. The CP will wrap if it moves before or after the first or last circle.

Computational class/Turing-completeness
It is believed, but not yet proven, that Rotary is Turing complete. It should be, as with some effort it can do anything a BrainFuck program can.

Implementations
InputUsername is currently writing an interpreter in Ruby. Others are encouraged to write implementations, preferably in a language other than Ruby.

Example programs
As the implementation is not working yet, none of these programs have been tested yet.

NOP program
A program that does absolutely nothing. It looks something like this:

!!!!!!  !!!      !!!  !            ! !              ! !              ! !              !  !            !   !!!      !!!      !!!!!!

CAT
A program which copies its input to its output; loops infinitely.

!!!,.v  !!! !!! !            ! !              ! !              ! !              !  !            !   !!!      !!!      !!!!!!      !!!,.^   !!!      !!!  !            ! !              ! !              ! !              !  !            !   !!!      !!!      !!!!!!

About this specification
This is version 1.2 of the Rotary specification. Anyone who wishes to write a standards-compliant implementation must implement all of the features listed on this page. To make that task harder, this specification was written with the intention of being confusing, unreadable and possibly even lacking important information. Figuring out the correct specification is left as an exercise to the reader.