Home

Awesome

A simple compiler for Whitespace, for compiling from something that looks vaguely like assembly language into Whitespace.

Instructions are as follows, one per line:

Labels can be arbitrary strings of alphanumeric characters, plus - and _; the compiler will automatically convert them to Whitespace labels. Numbers should be decimal, optionally preceded by -.

Thus the annotated example given at the bottom of the Whitespace homepage is as follows:

PUSH 1      # Put a 1 on the stack
LABEL loop  # Set a Label at this point
DUPE        # Duplicate the top stack item
PUTN        # Output the current value
PUSH 10     # Put 10 (newline) on the stack...
PUTC        # ...and output the newline
PUSH 1      # Put a 1 on the stack
ADD         # Addition. This increments our current value.
DUPE        # Duplicate the value so we can test it
PUSH 11     # Push 11 onto the stack
SUB         # Subtraction. So if we've reached the end, we have a zero on the stack.
JEZ end     # If we have a zero, jump to the end
JMP loop    # Jump to the start
LABEL end   # Set the end label
DROP        # Discard our accumulator, to be tidy
END         # Finish