Swirly

From Esolang
Jump to navigation Jump to search

Swirly is a forth derivative with static types, which compiles to uxntal, created by isabelle cedar. It uses state switching to switch between a text, type, compile, and code stack.

States

A swirly program starts in the ~text state. To change states, write ~[state]. The available states are

- ~text

- ~type

- ~code

- ~compile

The text state is contains text, and is ignored by the compiler. It can be used to create comments in the literate programming style.

Types

- # denotes a 16-bit unsigned integer, or short

- ' denotes an 8-bit unsigned integer, or char

- x [ denotes a pointer to x, which is a 16 bit address

- x -> y denotes a function taking x and returning y. x and y can both be more than one type, if the function takes multiple arguments or returns multiple values, or omitted if there are no arguments or return values.

Some Words

A non-exhaustive list of the words in swirly:

word description
+ #a #b -- #a+b
- #a #b -- #a-#b
* #a #b -- #a*#b
/ #a #b -- #a÷b
#2' convert a # to a '
'2# convert a ' to a #
device-out ( a# b' -- ) write # a to a device b
device-out' ( a' b' -- ) write ' a to a device b

Examples

Set the screen size

8 3 * Screen/width 8 3 * Screen/height

Set the system colors

65535 System/r
64481 System/g
63810 System/b

Draw a sprite to the screen

%;picn% Screen/addr
00 Screen/y
00 Screen/x 01 Screen/sprite
%BRK%
%@picn% %3c7e% %ffff% %ffff% %7e3c%