Skip to main content

What makes a program?

1. Program and Instructions​

A program is composed of lines of code, or specifically, instructions in hexadecimal format.

Each line of code consists of five bytes. The first byte is the opcode, while the subsequent 4 bytes are used as four 8-bit operands or parameters labeled P00, P01, P10, and P11.

For example, the 0F opcode signifies program termination regardless of the values of parameters P00 through P11. In some cases, such as instruction 0E for jumping to another line, parameters P10 and P11 are interpreted as merged components of a 16-bit parameter referred as P-1. Similarly, P00 and P01 can be treated as one 16-bit parameter P-0 for certain opcodes. In the code, all elements in a code line are input in hexadecimal.

2. Program Lines​

We can freely edit 512 lines of the program, with all line numbers from 0000 to 01FF being valid.

Line jump instructions, either conditional or unconditional, are often used when concepts like IF statements and loops are needed.

Assembly and machine code

The concept of instruction and opcodes used in the JoyKit were inspired from Solaris x86 Assembly Language.

warning

Remark: Not all parameters necessarily participate in the execution of an instruction.

Some specific instructions do not need operands. For instance, end of program instruction 0F, Return instruction 0D, the operands will be ignored.

caution

Sometimes the bits in an OP is interpreted bitwise, or values may not be considered as numbers.

INST_Delay

When using delay instruction 02, P-0 and P-1 represent value and unit repectively.

INST_PROG_DELAYCMDP-0P10P11
Delay 1000 ms0203E80000
02 03E8 0000

in which hexadecimal value 03E8 of OP-0 equals to 1000 in decimal,while OP-1 0000 determines unit of milliseconds.

INST_SET_LED_COLOUR

Another example is opcode E4 for setting colours of the WS2812B full-colour LED.

E4 00 FF 80 00

Meaning that LED with index 00 is set to orange represented by FF8000.

RGB
FF8000

The operand values are therefore:

P00P01P10P11
00FF8000
tip

In the combo key description (such as →+↺️) in this document, the first key (→) is pressed and held, and then the second key (↺) is pressed.