-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation
Troughout the documentation, you'll find different annotations for many things. Ill try to clarify anything here.
This is my way of adding type annotation to the documentation!
-
any: Any value representable in a scratch variable -
str: Exclusively a text -
int: Exclusively a number -
reg: An index pointing to a register
When I say base 0, that means that indexes start at 0. When I say base 1 the indexes work like in scratch.
Registers are the temporary variables of a program. Every program gets 16 Registers for themselves, indexed from 1 to 16
Memory is the RAM of Azure. It is indexed base 0
Program Memory, happens when the program is running in user mode, which limits the readeable and writeable range to the program memory and offsets it to make index 0 be the start of program memory
The heap is literally just a long list where you can write into with base 1
The program runs in two easy steps every tick:
- Get OPCODE: This fetches the next instruction OPCODE and Arguments
- Run Command: This runs the selected OPCODE. Writing and Reading is handled then by internal functions
NOOP
Does nothing
EXIT
Exits the program
JMP pc:int
Jumps to instruction pc in program memory
CALL pc:int
Pushes current pc to stack and jumps to pc can be returned to using #OPCODES#RET
RET
Pops the top pc from stack and jumps to it. Needs #OPCODES#CALL to be used first
SYSCALL key:str
Raises a syscall trap to key
MOV des:reg val:any
Sets the registry des to val (Not required to be int)
COPY orig:reg des:reg
Copies the value in registry orig into registry des
ADD/SUB/MULT/DIV/MOD des:reg val:reg
Runs the specific operation on the registry des with the registry val
- ADD: Addition (+)
- SUB: Subtraction (-)
- MULT: Multiplication (*)
- DIV: Division (/)
- MOD: Modulo (%)
CMP reg1:reg reg2:reg
Compares reg1 to reg2 and sets the corresponding flags (EQ, LT, GT, ZF)
JEQ/JLT/JGT/JZ/JNZ pc:int
Jumps to instruction pc if the corresponding condition is true
- JEQ: Equal (EQ) flag is
true - JLT: Less than (LT) flag is
true - JGT: Greater than (GT) flag is
true - JZ: Zero (ZF) flag is
true - JNZ: Zero (ZF) flag is
false
ALLOC amount:int reg:reg
Allocates amount spaces in heap and returns index to registry reg
READMEM addr.int reg:reg
Returns the value at program memory addrinto registry reg
WRITEMEM addr:int reg:reg
Writes the value at register reg to program memory addr
READHEAP pointer_reg:reg des_reg:reg
Returns the value at heap index of registry pointer_reginto registry des_reg
WRITEHEAP pointer_reg:reg val_reg:reg
Writes the value at registry val_reg into heap index of registry pointer_reg
EXTERNAL key:str
Calls an external function (key)
SYSRET
Just like #OPCODES#RET, but also sets trap status and mode
Here you'll see every every Syscall function indexed by register:type
1:str
Logs the value at 1 to the Scratch Addons/Turbowarp Debugger