Skip to main content

Assembler for the Whitespace Programming Language

Project description

Makefile CI

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

Mnemonic 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

Mnemonic Parameter Description
add Addition
sub Subtraction
mult Multiplication
div Integer Division
mod Modulo

Heap Access

Mnemonic Parameter Description
store Store
retr Retreive

Flow Control

Mnemonic 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

Mnemonic 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 whitespace
    • mark (default): whitespace is preceeded by S (space), T (tab), and L (newline)

Example:

whitespace-asm hello-world.wsasm --output hello-world.ws

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whitespace_asm-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

whitespace_asm-1.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file whitespace_asm-1.0.0.tar.gz.

File metadata

  • Download URL: whitespace_asm-1.0.0.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

Hashes for whitespace_asm-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a834e354c89c6cb6ecd1f1b83f392397af8c04d4ad382902ce226f98931e0140
MD5 aae9b32cd023733f6c3afea089577044
BLAKE2b-256 0ddcfb02ccde6eddaeba95a01a511380f06b8a88b5ae0616bbbb402c2792adac

See more details on using hashes here.

File details

Details for the file whitespace_asm-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: whitespace_asm-1.0.0-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

Hashes for whitespace_asm-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 830c0f330a0811513d7e8eed9a2742ee28d2c69a1b4c8247e5bde1f0e48faa41
MD5 16782af92b614076b790a95c301402c4
BLAKE2b-256 33ff38999203eaa7ac2e4b8ea7a49d134d2b724d9b19d715a5f14eca95099b74

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page