ASMbot reference manual

ASMbot allows you to control a simple robot on a 2D grid.

ASMbot is controlled using programs written using a custom assembly-like language. This document gives an overview of the language syntax as well as all the available instructions and their behavior.

Syntax

Each line is an instruction. An instruction consists of tokens separated by spaces. The first token is a mnemonic that denotes the instruction, any remaining tokens are arguments.
Arguments can be either addresses (e.g. [123] is the memory address 123) or literals (e.g. 123 is a literal value of 123).

All values in the VM are integers. Results of computations and other values are stored in one contiguous memory space that is addressed using integer addresses. Reading from a memory address that has never been assigned to causes an error.
Note: Memory addresses can be both negative and positive. Negative addresses do not denote indexing from the end of the memory space, but are distinct memory locations.

Comment lines begin with // and are skipped when executing the program. Blank lines inside the program are forbidden.
Note: All lines, including comment lines, are counted when calculating instruction offsets for jz.

Instructions

Notation:

Note: The square, round and angle brackets around arguments are just a notation used in this reference manual. They should not be used when writing programs. (Note that square brackets are used when writing programs, but they have a different meaning.)

Available instructions:

Performance

The current VM provides no hard gurantees about performance. However, speeds of up to 5M instructions/seconds have been observed when rendering pauses are reduced to a minimum. The current VM takes comparatively frequent rendering pauses to ensure responsiveness. Because of this approximately 840k instructions/second can be executed when 5x speed is activated. (These results were obtained on a relatively modest school-provided laptop.)

Also note that because of restrictions placed on background processing by browsers the VM tends to stop/slow down dramatically when it is not visible on the screen (running in a background tab or minimized).

Some performance statistics are logged to the debug console when the VM is running. However, note that having the debug console/DevTools open while the VM is running can significantly reduce performance.