This is an intro to the Nucleus game and the kaon language. The goal is to write a program (quark) that will outlive every other program, in a shared memory core. # Installation instructions You can install lepton (the implimentation of nucleus) using flakes or cargo (TODO!). Using nix flakes: `nix run git+https://time.ta.rdis.dev/el/lepton` Using cargo: `cargo install leptonvm(!)` (TODO!) # Tutorial The "core" is a linear sequence of random-access memory, 4096 instructions wide. Access are 0-indexed and wrap around (Address 4096 is the same as address 0) Example core (4 instructions wide)
Index | Instruction |
---|---|
0 |
JUMP |
1 |
ADD |
2 |
JUMP |
3 |
DIE |
Instruction syntax |
Arguments |
Results |
Notes |
|
x: The source address; y: the destination address |
Copies value x to y |
y should not be constant. |
|
x: any value; y: any value |
Compares x to y and sets the equality flag if they are |
Only compares equality |
|
x: any value; y: any value |
Compares the instruction type of a to b. Sets the flag if they are |
|
|
a: any address |
Jumps to a if the equality flag is set
(i.e. the last |
A constant is treated as an absolute address. |
|
a: any address |
Moves execution of the current thread to address a. |
A constant is treated as an absolute address. |
|
a: any value; b: any address |
Adds a to b and stores the result in b |
b should not be constant. If b is constant, the program dies. |
|
a: any value; b: any address |
Subtracts a from b and stores the result in b |
b should not be constant. If b is constant, the programs dies. |
|
a: any value; b: any address |
Multiplies a and b and stores the result in b |
b should not be constant. If b is constant, the programs dies. |
|
a: any value; b: any address |
divides a by b and stores the value in b |
b should not be constant. The value of b should not b 0. If either of these is true, the program dies. |
|
x: any literal |
If this instruction is executed, the program stops. However, it stores data for use by other instructions. |
Magic death trap |