A simple paper computer

67d450b New dependency and bump version

~jummit pushed to ~jummit/hase git

13 days ago

be4b134 Step for a thousand cycles

~jummit pushed to ~jummit/hase git

13 days ago

#Hase Paper Computer

A simple language for paper-computing.


l:[1 2 3 0]

; sum the values


cargo instal --path .

#Getting Started

#Defining Registers

The hase virtual machine is initialized with a set of registers, which have one-character long names.

They can be specified to be a set size like this:

; Register with five empty slots:

Registers initialy have empty slots (value 0).

Registers can also be pre-filled with values:

; Register with the values 1, 2 and 3:
r:[1 2 3]

Each register has a movable pointer which starts at the first slot.

; pointer on the first slot
; r:[[1] 2 3]
r:[1 2 3]

; move right instruction

; pointer on the second slot
; r:[1 [2] 3]


Each line begins with a register name, followed by an instruction.

; move left operation on the register "n"

Most operations also require a value, which can be a number or the current value of a register:

; add one
; add the value a register is pointing to

Move Right (>)

Move the pointer of a register to the right by the given amount.

The cursor wraps around (the slots are arranged in a circle).

Move Left (<)

Same as move right, just backwards.

Take (v)

Move values from the second register to the first (empty the second, add it to the first).

Add (+)

Add the value to the register.

Subtract (-)

Subtract the value from the register.

Values can never be lower than zero.

Jump (n)

Jump to the given label when the register is not empty.

Labels are defined by adding a number to a line:

an1; jump to label one
=0; was zero
1=1; was one

Result (=)

Stops the program and returns the result.

This instruction can be used in two different ways:

Returning a value:


Returning an entire register:


When the virtual machine runs out of instructions, every register is returned for inspection.