A human readable assembler format and compiler for the whitespace programming language
This Assembler was written at 1:00 in the morning as a proof of concept, because I was bored. It probably features bugs. Feel free to report them as issues.
There are probably a bunch of better assemblers/compilers outputting whitespace out there, I'd highly reccomend looking around for them.
Compile the C# Project
Run WhitespaceAssembler.exe with the input and output file destinations as Parameters
Numbers can be input as simple decimal integers, #hexadecimal values (prefixed with #) or as 'A' Ascii characters (' ' is currently not supported, use Ascii code 32 instead.
Variables have two prefixes depending on if you are talking about their Value or their Address. They do not need to be declared. *variableName retrieves the value at the given variable (Like a Pointer dereference) &variableName gets the address of the Variable
Labels are prefixed with a . and can be defined with the lbl command
The instructions are followed by any of the following symbols, describing the parameter type. (parameters in code are seperated by spaces or tabs)
# Means a Number Value or an Address (&variableName)
* Means a Variable Value (*variableName)
. Means a Label
Pushes the Value or Address to the Stack
Pushes the Variable Value to the Stack
Duplicates the top Value of the Stack
Discards the top Value of the Stack
Adds the two Values on top of the Stack and stores the result on the Stack
Adds the Values on top of the Stack to the Value or Address in Param0 and stores the result on the Stack
Adds the Values on top of the Stack to the Variable in Param0 and stores the result on the Stack
Adds the Variable in Param0 to the Value or Address in Param1 and stores the result on the Stack
Adds the Value or Address in Param1 to the Variable in Param0 and stores the result on the Stack
Adds the Variable in Param1 to the Variable in Param0 and stores the result on the Stack
Subtracts the two Values on top of the Stack and stores the result on the Stack
Subtracts the Values on top of the Stack from the Value or Address in Param0 and stores the result on the Stack
Subtracts the Values on top of the Stack from the Variable in Param0 and stores the result on the Stack
Subtracts the Variable in Param0 from the Value or Address in Param1 and stores the result on the Stack
Subtracts the Value or Address in Param1 from the Variable in Param0 and stores the result on the Stack
Subtracts the Variable in Param1 from the Variable in Param0 and stores the result on the Stack
Multiplies the two Values on top of the Stack and stores the result on the Stack
Multiplies the Values on top of the Stack with the Value or Address in Param0 and stores the result on the Stack
Multiplies the Values on top of the Stack with the Variable in Param0 and stores the result on the Stack
Multiplies the Variable in Param0 with the Value or Address in Param1 and stores the result on the Stack
Multiplies the Value or Address in Param1 with the Variable in Param0 and stores the result on the Stack
Multiplies the Variable in Param1 with the Variable in Param0 and stores the result on the Stack
Divides the two Values on top of the Stack and stores the result on the Stack
Divides the Values on top of the Stack with the Value or Address in Param0 and stores the result on the Stack
Divides the Values on top of the Stack with the Variable in Param0 and stores the result on the Stack
Divides the Variable in Param0 with the Value or Address in Param1 and stores the result on the Stack
Divides the Value or Address in Param1 with the Variable in Param0 and stores the result on the Stack
Divides the Variable in Param1 with the Variable in Param0 and stores the result on the Stack
Gets the Modulo of the two Values on top of the Stack and stores the result on the Stack
Gets the Modulo of the Values on top of the Stack and the Value or Address in Param0 and stores the result on the Stack
Gets the Modulo of the Values on top of the Stack and the Variable in Param0 and stores the result on the Stack
Gets the Modulo of the Variable in Param0 and the Value or Address in Param1 and stores the result on the Stack
Gets the Modulo of the Value or Address in Param1 and the Variable in Param0 and stores the result on the Stack
Gets the Modulo of the Variable in Param1 and the Variable in Param0 and stores the result on the Stack
Stores the Value at the second topmost Stack at the Address on top of the Stack
Stores the Value on top of the Stack at the Address in Param0 (This is kind of the reverse behaviour of the Store instruction but Store at Address is pretty handy)
Stores the Value Or Address in Param0 at the Address in Param1
Replaces the Address on top of the Stack with the value at said Address
Retrieve # Pushes the Value at the Address in Param0 on top of the Stack
Defines a Label as param0
Calls the Label specified in Param0
Jumps to the Label specified in Param0
Jumps to the Label specified in Param0 if the value on top of the Stack is zero (This pops the top of the stack so call Dup before, if you want to keep the Value)
Jumps to the Label specified in Param0 if the value on top of the Stack is negative (This pops the top of the stack so call Dup before, if you want to keep the Value)
Returns from a Call
Stops the Program
Prints the character on top of the Stack to the Console
Prints the number on top of the Stack to the Console
Reads a character from the Console and puts it on top of the Stack
Reads a number from the Console and puts it on top of the Stack