Files
tyche/doc/VM
2026-04-26 20:22:47 -05:00

43 lines
1.1 KiB
Plaintext

Supported types
---------------
Nil
Integer
Float
String
Array
Table
Function
NativePointer
Operations
----------
Stack operations:
pshn [int] Push int
pshz Push zero (or false)
psht Push true
pshr [float] Push float (real)
pshs [string] Push string
pshf [function] Push function
newa [array] Push (create) empty array
newt [table] Push (create) empty table
pop
dup
Local variables:
setl [int] Set stack top as indexed local variable
getl [int] Get indexed local variable and place on stack
Function operations:
call [n_pars] Enter function on stack toplevel (passing n next stack values as parameters)
ret Leave a function (return value in stack)
retn Leave a function (return nil)
Control flow:
bz [pc] Branch if zero
bnz [pc] Branch if not zero
jmp [pc] Unconditional jump
Logical/arithmetic
sum Sum top 2 values in stack
mul Multiply top 2 values in stack