Specification

Version 0.1

Contents

  1. Source Format
  2. Memory Model
  3. Execution
  4. Instruction Semantics

1. Source Format

A Byte Syze program takes the form of a binary file, no longer than 256 bytes.  This binary data constitutes the initial state of the program's working memory.

2. Memory Model

The working memory consists of 256 bytes, indexed in zero-based fashion.  On startup, the working memory is initialised to the program code.  Given a source file n bytes long, the program code is loaded into bytes 0 to n − 1, and the remaining bytes are initialised to zero.

There are also four registers, which are each a byte in syze.  They are:

The entire program state at any time is encoded in the working memory and these four registers.

3. Execution

A byte is read from the memory space at the address pointed to by the IR.  The IR is then incremented, and then the instruction represented by the byte that was read is executed.

If after executing an instruction (including a nop) the IR contains the value 255, the instruction at that byte is read and executed and then the program halts.  The value in the DR becomes the program's exit code.

4. Instruction Semantics

This table gives the available instructions and the byte value that represents each.

Byte value Instruction
Dec Hex ASCII
60 3C < Copies the value at the memory address indexed by AR into DR.
62 3E > Copies the value from DR into the memory address indexed by AR.
42 2A * Swaps the values contained in DR and AR.
33 21 ! Swaps the values contained in AR and IR.
92 5C \ Swaps the values contained in DR and SR.
43 2B + Adds together the value in DR and the value at the memory address indexed by AR.  Stores the result in DR.
45 2D - Subtracts the value at the memory address indexed by AR from the value in DR.  Stores the result in DR.
40 28 ( Receives a byte from the standard input and stores it in DR.  If EOF of the standard input is reached, DR will receive the value 0.
41 29 ) Writes the byte stored in DR to the standard output.
63 3F ? If the value contained in DR is 0, increments IR by 1.

Implementations may perform I/O in ASCII or any of its 8-bit supersets.

Any byte not listed here denotes a nop.  (Note: Only the byte value 0 is guaranteed to remain a nop in future versions of Byte Syze.)