Assembler for the Whitespace Programming Language
Project description
whitespace-asm
Assembler for the Whitespace Programming Language. It generates a Whitespace program based on a file containing a set of keywords instead of having to type in whitespace characters.
See the Whitespace Tutorial for details on the Whitespace language.
Keywords
Keywords are case-insensitive.
Stack Manipulation
Keyword | Parameter | Description |
---|---|---|
push |
<value> |
Push the value onto the stack |
dup |
Duplicate the top item on the stack | |
copy |
<number> |
Copy the nth item on the stack (given by the argument) onto the top of the stack |
swap |
Swap the top two items on the stack | |
pop |
Discard the top item on the stack | |
slide |
<number> |
Slide n items off the stack, keeping the top item |
Arithmetic
Keyword | Parameter | Description |
---|---|---|
add |
Addition | |
sub |
Subtraction | |
mult |
Multiplication | |
div |
Integer Division | |
mod |
Modulo |
Heap Access
Keyword | Parameter | Description |
---|---|---|
store |
Store | |
retr |
Retreive |
Flow Control
Keyword | Parameter | Description |
---|---|---|
label |
<label> |
Mark a location in the program |
call |
<label> |
Call a subroutine |
jump |
<label> |
Jump unconditionally to a label |
jumpz |
<label> |
Jump to a label if the top of the stack is zero |
jumpn |
<label> |
Jump to a label if the top of the stack is negative |
ret |
End a subroutine and transfer control back to the caller | |
end |
End the program |
I/O
Keyword | Parameter | Description |
---|---|---|
outc |
Output the character at the top of the stack | |
outn |
Output the number at the top of the stack | |
inc |
Read a character and place it in the location given by the top of the stack | |
inn |
Read a number and place it in the location given by the top of the stack |
Comments
Comments may be on a separate line or may be inline. Comments start with ;
. Example:
;This a comment
push 'H' ;Stack = 'H'
outc ;Output 'H'
Parameters
<number>
<number>
is just an integer value. It may be positive or negative. Examples:
42
-33
<value>
<value>
may either be a <number>
or a character. A character is enclosed in single quotes.
Backslash may be used for characters like newline ('\n'
). Examples of characters:
' '
'H'
';'
'\n'
- Newline'\''
- Single quote'\\'
- Backslash
<label>
<label>
is a number that consists of just zeros and one. Examples:
011
10101
CLI
Assemble
Assemble a Whitespace program:
whitespace-asm <input> [-o/--output <output>] [-f/--format <format>]
where:
<input>
is the path to the input Whitespace Assembly file<output>
is the optional path to output Whitespace file. If not specified, change the extension of<input>
to.ws
<format>
is the optional output format type:raw
: just whitespacemark
(default): whitespace is preceeded byS
(space),T
(tab), andL
(newline)
Example:
whitespace-asm hello-world.wsasm --output hello-world.ws
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file whitespace_asm-1.0.1.tar.gz
.
File metadata
- Download URL: whitespace_asm-1.0.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/6.8.0-1015-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77ec813f7cfdc1368ea96ae073f844fe36158ae2792ee7bd34a576c08e9203af |
|
MD5 | 3404ec2f6e29c73fbe885f2ec3d73165 |
|
BLAKE2b-256 | 08d8f4c8b02ff67bf9da5620eeca20e7b8a6449ad24c9879a363ca139716a0b2 |
File details
Details for the file whitespace_asm-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: whitespace_asm-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/6.8.0-1015-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 077e91136095b94bc11b8841900426f1ad1aa1347a66eebe432c6d6de1f03c9f |
|
MD5 | bcd18ac400a2e1ad23651db947f696aa |
|
BLAKE2b-256 | eb05f63ab77fcee2928a6a7570730acc1692898952fad2ce8ac5780ce4ea94df |