This page is still being worked on!
RoundAbout is a twodimensional esoteric programming language. Code is placed on a twodimensional grid, called Map.
Language overview
A RoundAbout program consists of a size definition and the actual program code inside. Each cell in the map consists of a single UTF8 character.
The program code is then executed by looking at the current symbol below the cursor, and then executing an instruction based on the selected mode. Any empty spaces should be considered a space (U+0020). At the start of execution the cursor is positioned on the topleft corner (at 0,0) and the direction is set to right. The following example is a CAT program
//21,2
$?; =+1; &^; @v; $+;
~
Instructions
Due to the fact that RoundAbout has multiple execution modes, each symbol can have different meanings in different contexts.
Contextless
These instructions can be used regardless of mode
Cmd

Name

Condition

Description

~

Halt

None

Halts the program execution

;

Reset

None

Sets the mode to Traversal

Traversal
Cmd

Name

Condition

Description

@

Setconditionaltraversal

None

Sets the mode to Conditional Traversal

?

Setcompare

None

Sets the mode to Comparison

&

Setflags

None

Sets the mode to Comparison

%

Setoperation

None

Sets the mode to Operation

=

Setstack

None

Sets the mode to Stack

[

Setheap

None

Sets the mode to Heap

$

Setio

None

Sets the nice to IO

#

Setmap

None

Sets the mode to Map

>

Flowright

None

Sets the direction to right

<

Flowleft

None

Sets the direction to left

v

Flowdown

None

Sets the direction to down

^

Flowup

None

Sets the direction to up

/

Flowfsreflect (forward slash reflect)

None

When direction is up or right, set direction to rightup. When direction is down or left, set direction to leftdown. When direction is rightdown, set direction to leftup. When direction is leftup, set direction to rightdown. Otherwise preserve direction

\

Flowbsreflect (back slash reflect)

None

When direction is up or left, set direction to leftup. When direction is down or right, set direction to rightdown. When direction is leftdown, set direction to rightup. When direction is rightup, set direction to leftdown. Otherwise preserve direction



Flowvreflect (vertical reflect)

None

When direction is right, set direction to left. When direction is left, set direction to right. When direction is rightdown or leftdown, set direction to down. When direction is rightup or leftup, set direction to up. Otherwise preserve direction



Flowhreflect (horizontal reflect)

None

When direction is down, set direction to up. When direction is up, set direction to down. When direction is rightdown or rightup, set direction to down. When direction is leftdown or leftup, set to left. Otherwise preserve direction

+

Flowpreflect (plus reflect)

None

Set direction randomly to either right, left, up, or down

x

Flowxreflect (cross reflect)

None

Set direction randomly to either rightdown, rightup, leftdown, leftup

*

Flowsreflect (star reflect)

None

Set direction randomly to either right, rightdown, rightup, left, leftdown, leftup, down, or up

Conditional traversal
This is an extension to the basic traversal mode where any instructions are only executed if ResultFlag is set to true.
Comparison
This mode is used to compare values on the stack, therefore to execute such an instruction the stack has to have at least two values.
Cmd

Name

Condition

Description

>

Comparegreaterthan

At least two values on the stack

Compares the two top most values (a, b) on the stack using b > a and sets ResultFlag to the result

<

Comparelessthan

At least two values on the stack

Compares the two top most values (a, b) on the stack using b < a and sets ResultFlag to the result

=

Compareequal

At least two values on the stack

Compares the two top most values (a, b) on the stack using b == a and sets ResultFlag to the result

!

Comparenotequal

At least two values on the stack

Compares the two top most values (a, b) on the stack using b != a and sets ResultFlag to the result

Flags
This mode is used to track results of certain instructions. The flags values are stored in a binary number that is arbitrarily large. Right now only six bits are used, but sixteen bits are reserved for runtime usage. This means when using custom you should either use bit 0 or use values above 65535 (2^16  1)
Reserved Bits Table

Name

Description

Bit 0

ResultFlag

This is a general flag that represent whether some action succeeded or not

Bit 1

ComplexRoot

Set when taking a root results in a complex value

Bit 2

DivisionByZero

Set when any division/modulo by zero is performed. Currently there are 3 scenarios: Division, Modulo, and 0th Root

Bit 3

ResultTruncated

Set when division had a remainder

Bit 4

ReadNoDigits

Set when Stackread read no digits

Bit 5

InvalidValue

Set when an invalid was passed to an instruction

Bit 6

Utf8Error

Set when encoding/decoing values using UTF8 codec failed

Bit 7

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Bit 8

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Bit 9

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Bit 10

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Bit 11

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Bit 12

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Bit 13

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Bit 14

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Bit 15

Reserved Bit

This is a reserved bit, but as of now has yet no functionality

Instructions
Cmd

Name

Condition

Description



Flagstrue

At least one value on the stack

Reads a number, if nonnegative then performs flags = flags  value . If read number is negative, set InvalidValue flag to TRUE

&

Flagsfalse

At least one value on the stack

Reads a number, if nonnegative then performs flags = flags & ~value . If read number is negative, set InvalidValue flag to TRUE

^

Flagsinvert

At least one value on the stack

Reads a number, if nonnegative then performs flags = flags ^ value . If read number is negative, set InvalidValue flag to TRUE

>

Flagspush

None

Pushes the Flags' value onto the stack

?

Flagspush

At least one value on the stack

Pops a value off the stack, if nonnegative then performs (flags & value) == value and saves the result to ResultFlag. If value is negative, set InvalidValue flag to TRUE

Operation
This mode is used for operating with values on the stack.
Cmd

Name

Condition

Description

+

Operationadd

At least two values on the stack

Pops two values of the stack and adds them together using b + a



Operationsub

At least two values on the stack

Pops two values of the stack and subtracts them from each other and pushes the result onto the stack using b  a

*

Operationmul

At least two values on the stack

Pops two values of the stack and multiplies them together and pushes the result onto the stack using b * a

/

Operationdiv

At least two values on the stack

Pops two values of the stack and performs integer division and pushes the result onto the stack using b / a

^

Operationpow

At least two values on the stack

Pops two values of the stack and calculates the power and pushes it onto the stack using b ^ a

\

Operationroot

At least two values on the stack

Pops two values of the stack and calculate the nth root and push the truncated result onto the stack using b√a

%

Operationmod

At least two values on the stack

Pops two values of the stack and performs integer division and pushes the remainder onto the stack them using b % a



Operationor

At least two values on the stack

a

&

Operationand

At least two values on the stack

Pops two values of the stack and performs bitwise AND and pushes the result onto the stack them using b & a

v

Operationxor

At least two values on the stack

Pops two values of the stack and performs bitwise XOR and pushes the result onto the stack them using b ^ a

>

Operationrshift

At least two values on the stack

Pops two values of the stack and performs bitwise right shift and pushes the result onto the stack them using b >> a

<

Operationlshift

At least two values on the stack

Pops two values of the stack and performs bitwise left shift and pushes the result onto the stack them using b << a

!

Operationinvert

At least one value on the stack

Applies bitwise inversion to the topmost item on the stack

Stack
Cmd

Name

Condition

Description

+

Stackpush

None

Read digits until a nondigit character is encountered and push read value onto the stack. If no digits were read, push 0



Stackpop

At least one value on the stack

Pops a value off the stack

*

Stackswap

At least two values on the stack

Swaps the two topmost values on the stack

>

Stacksave

At least one value on the stack

Pop a value off the stack and set it to the current cell in the heap

<

Stackload

None

Push a value equal to the current cell in the heap

?

Stackany

None

Set ResultFlag to true if stack is not empty, otherwise set to false

:

Stackdupe

At least one value on the stack

Duplicates the top value on the stack

&

Stackclear

None

Clears the stack

Heap
Cmd

Name

Condition

Description

>

Heaprshift

None

Moves cell pointer right

<

Heaplshift

None

Moves cell pointer left

#

Heapjump

At least one value on the stack

Pops a value off the stack and moves pointer to such place

*

Heaphome

None

Move cell pointer to 0

+

Heapincrement

None

Increment value in current cell by one



Heapdecrement

None

Decrement value in current cell by one

0

Heapnull

None

Set value in current cell to 0

&

Heapclear

None

Set all cells to 0

IO
Cmd

Name

Condition

Description

+

IOwrite

At least one value on the stack

Pop a value off the stack and write it to STDOUT using UTF8 encoding



IOread

None

Read a UTF8 character from STDIN and push it's value onto the stack. If no character is read, push 1

?

IOany

None

If a character can be read from STDIN set ResultFlag to true, otherwise set to false

Map
Cmd

Name

Condition

Description

+

Mapread

None

Advance cursor, read a UTF8 character from the map at current location and push it's value onto stack



Mapwrite

At least one value on the stack

Advance cursor, pop a value off the stack, convert it to a UTF8 character and set write it to the current location on the map

*

Mapnull

None

Advance cursor, set the character at current location to a space (U+0020)

#

Mapjump

At least two values on the stack

Pop two values off the stack (y, x) and then set cursor location to (x, y). If outofbound, wrap around

>

Mapwincrement (width increment)

None

Increase the map's width by one

<

Mapwdecrement (width decrement)

Map width greater than 1

Decrease the map's width by one

v

Maphincrement (height increment)

None

Increase the map's height by one

^

Maphdecrement (height decrement)

Map height greater than 1

Decrease the map's height by one

W

Mapreadwidth

None

Push a value onto the stack equal to the map's width

H

Mapreadheight

None

Push a value onto the stack equal to the map's height

X

Mapreadx

None

Push a value onto the stack equal to the cursor's X coordinate

Y

Mapready

None

Push a value onto the stack equal to the cursor's Y coordinate
