.
This commit is contained in:
63
doc/OPCODES
63
doc/OPCODES
@@ -22,12 +22,13 @@ Stack operations:
|
||||
a0 c0 e0 pushi [int] Push int
|
||||
a1 c1 e1 pushc [index] Push constant
|
||||
a2 c2 e2 pushf [function] Push function id
|
||||
00 pushz Push zero (or false)
|
||||
01 pusht Push true
|
||||
02 newa Push (create) empty array
|
||||
03 newt Push (create) empty table
|
||||
04 pop
|
||||
05 dup
|
||||
00 pushn Push nil
|
||||
01 pushz Push zero (or false)
|
||||
02 pusht Push true
|
||||
03 newa Push (create) empty array
|
||||
04 newt Push (create) empty table
|
||||
05 pop
|
||||
06 dup
|
||||
|
||||
Local variables:
|
||||
a3 c3 e3 pushv [int] Push n nil values into the stack (used to init local vars)
|
||||
@@ -44,12 +45,12 @@ Function operations:
|
||||
Table and array operations:
|
||||
16 getkv Get table's value based on key (pull 1 value, push 1 value)
|
||||
17 setkv Set table's key and value (pull 2 values from stack)
|
||||
18 geta Get array's position value
|
||||
19 seta Set array's position value (pull 2 values from stack)
|
||||
1a appnd Add value to the end of array
|
||||
1b next Push the next pair into the stack (for loops)
|
||||
1c smt Set value metatable
|
||||
1d mt Get value metatable
|
||||
a8 c8 e8 geti Get array's position value
|
||||
a9 c9 e9 seti Set array's position value
|
||||
18 appnd Add value to the end of array
|
||||
19 next Push the next pair into the stack (for loops)
|
||||
1a smt Set value metatable
|
||||
1b mt Get value metatable
|
||||
|
||||
Logical/arithmetic:
|
||||
20 sum Sum top 2 values in stack
|
||||
@@ -57,24 +58,24 @@ Logical/arithmetic:
|
||||
22 mul Multiply top 2 values in stack
|
||||
23 div Float division
|
||||
24 idiv Integer division
|
||||
25 eq Equality
|
||||
26 neq Inequality
|
||||
27 lt Less than
|
||||
28 lte Less than or equals
|
||||
29 gt Greater than
|
||||
2a gte Greater than or equals
|
||||
2b and Bitwise AND
|
||||
2c or Bitwise OR
|
||||
2d xor Bitwise XOR
|
||||
2e pow Power
|
||||
2f shl Shift left
|
||||
30 shr Shift right
|
||||
31 mod Modulo
|
||||
25 mod Modulo
|
||||
26 eq Equality
|
||||
27 neq Inequality
|
||||
28 lt Less than
|
||||
29 lte Less than or equals
|
||||
2a gt Greater than
|
||||
2b gte Greater than or equals
|
||||
2c and Bitwise AND
|
||||
2d or Bitwise OR
|
||||
2e xor Bitwise XOR
|
||||
2f pow Power
|
||||
30 shl Shift left
|
||||
31 shr Shift right
|
||||
|
||||
Other value operations:
|
||||
40 len Get table, array or string size
|
||||
41 type Get type from value at the top of the stack
|
||||
b0 cast [type] Cast type to another type
|
||||
aa cast [type] Cast type to another type
|
||||
42 ver Return VM version
|
||||
|
||||
External code:
|
||||
@@ -82,12 +83,14 @@ External code:
|
||||
49 asmbl Assemble code to bytecode format
|
||||
4a load Load bytecode as function (will place function on stack)
|
||||
|
||||
Control flow:
|
||||
a8 c8 e8 bz [pc] Branch if zero
|
||||
a9 c9 e9 bnz [pc] Branch if not zero
|
||||
aa ca ea jmp [pc] Unconditional jump
|
||||
Control flow (the destination is always a 16-bit field):
|
||||
ca bz [pc] Branch if zero
|
||||
cb bnz [pc] Branch if not zero
|
||||
cc jmp [pc] Unconditional jump
|
||||
* Jumps can only happen within the same function.
|
||||
|
||||
Memory management:
|
||||
4b gc Call garbage collector
|
||||
|
||||
Error handling: (0xa0~0xaf)
|
||||
???
|
||||
|
||||
Reference in New Issue
Block a user