Instruction structure

NoCode is the binary format of data that contain code for NoSense interpreter. Every instruction (opcode) of this code consists of two general parts - the instruction header and parameters.

Instruction structure

Instruction header

Instruction header takes 2 bytes. First byte consists of four 2-bit values (we can treat them as unsigned integer values in range 0 .. 3). They mean:

CC
Opcode category
11
Addressing mode of the first parameter
22
Addressing mode of the second parameter
33
Addressing mode of the third parameter

Second byte is the opcode number (usually called "code" in this documentation).

As you can see, the instruction is identified by the category and the number. There could be maximally 4*256 = 1024 opcodes. There are less opcodes in fact, but they have to be identified this way because they amount is more than 256. Different kinds of the instruction (e.g. ADD1i and ADD8f are completely different instructions and have different codes.

Parameters

There can be at most 3 parameters for the instruction. They count depends on the instruction number (code). The size of the parameter is relative to the instruction number and the addressing mode for that parameter.

Addressing mode 0

This addressing mode should be defined for the parameter that is unused in a particular instruction. Many instructions use only first or first and second parameters, or even no parameters.

Addressing mode 1

Addressing mode 1

This addressing mode means that value lie in place of the instruction parameter. The size of this parameter is the size of the value that is expected in a particular instruction.

You can imagine this as the indirect constant value written in a high level laguage code.

Addressing mode 2

Addressing mode 2

This addressing mode means that parameter has the size equal to 4 bytes, type [4i] and contains address that points on the value somewhere in the memory.

You can imagine this as a variable name in a high level laguage code.

Addressing mode 3

Addressing mode 3

This addressing mode means that parameter has the size equal to 4 bytes, type [4i] and contains address that points on the next value that contains address. This second address points to the value.

You can imagine this as a pointer in a high level laguage code.