Home

Awesome

WSA

Whitespace interpreter and visualiser / debugger.

(Work in progress, proof of concept, side project, might not update in a while)

It also compiles a modified version of Burghard's WSA

Machine details

Targeting compatibility with Lazy wspace, the following assumptions are in place:

Memory layout convention

The stdlib defined by this repo sets a couple of conventions to perform calls and manage the heap.

To start off, the default convention for calls is pass arguments through the stack, pushing them in the original order. The call will consume all of the arguments, removing them from the stack, and it will push as many return values as defined for that function (0-infinite).

Strings, vectors, etc. Must be allocated in the heap, and are always passed by reference.

The heap is split in 2 pieces: A stack, used to store local variables, and a heap, where blocks can be allocated or freed.

The heap stack helps storing temporary values. Usually, the native stack will suffice, but it has a few disadvantages:

With the heap stack, each function can assume that their stack is empty, and then use as much space as they need with something that the offsets will remain stable while performing operations. There's a tradeoff with a small performance hit though, since reading and writing from the heap stack requires multiple operations.

The memory layout is as follows:

Stack

The standard library on memory provides a few methods to deal with heap stack:

Heap

The heap tries to stay as much to the end of the memory as possible. Each entry will have:

The standard library on memory provides few methods to deal with heap:

Assembly language

It's based on Burghard's WSA as assembly language, but with a few modifications:

Extensions

While on debug mode, this interpreter adds some language extensions to debug or increase performance. For this, a few more operations are added, both to the assembler and the whitespace code ops:

As these are not whitespace standard, the assembler will omit the debugger instruction if the extension is not enabled, and throw an Error for the bitwise operations.

STD lib

This assembler has a few (WIP) std libraries with common operations. The ones dealing with the memory convention explained above can be imported with include memory.

The source of these libraries can be found in src/wsa/lib

Memory

See Memory layout convention

Bitwise

This library uses the language extensions if they are enabled, otherwise uses the standard 0.3 WS opcodes.

IO

Math