Skip to content

Latest commit

 

History

History
96 lines (95 loc) · 23.9 KB

opcodes.md

File metadata and controls

96 lines (95 loc) · 23.9 KB

The first three columns of this table identify the opcode of the table, in the chl file. They are named in this order: Type, Subtype, Datatype. They were removed to provide a better table view.

In Out V3In V3Out Name Description
0 END End of a script.
1 1 1 WAIT If popped bool is true then jumps to the instruction address pointed to by the parameter which must be behind the current instruction.
1 2 1 WAIT If popped bool is true then jumps to the instruction address pointed to by the parameter which must be after the current instruction.
2 1 1 1 VPUSH Push the integer stored in the Parameter field onto the normal stack.
2 1 2 1 VPUSH Push the float stored in the Parameter field onto the normal stack.
2 1 3 1 1 VPUSH Pop a float from the v3dstack and push it onto the normal stack. This is usually performed 3 times for moving coordinates from v3dstack to normal stack.
2 1 6 1 VPUSH Push the bool stored in the Parameter field onto the normal stack.
2 1 7 1 VPUSH Pushes the variable located at the index stored in the float in the parameter field.
2 2 7 1 VPUSH Pushes the object id stored in the variable indexed by the float in the parameter field onto the stack. This is usually used when making engine calls.
3 1 1 VPOP Pops a value off the stack. Effectively deleting it.
3 1 VPOP Pops a value off the normal stack and stores the value into the variable indexed by the integer in the parameter field.
4 1 2 1 ADD Pops 2 integers from the stack, adds them, and pushes the result onto the stack.
4 2 2 1 ADD Pops 2 floats from the stack, adds them, and pushes the result onto the stack.
4 3 2 1 ADD Pops 2 vectors from the v3dstack, adds them, and pushes the result onto the v3dstack.
5 1 0 * * * * CALL Makes an engine call to a native function. The native function is identified by an integer value in the parameter. The stack can be altered in many ways.
6 1 2 1 MINUS Pops 2 integers from the stack, subtracts the first from the second, and pushes the result onto the stack.
6 2 2 1 MINUS Pops 2 floats from the stack, subtracts the first from the second, and pushes the result onto the stack.
6 3 2 1 MINUS Pops 2 vectors from the v3dstack, subtracts the first from the second, and pushes the result onto the v3dstack.
7 1 1 1 UMINUS Pops an integer from the stack, negates it, and pushes the result onto the stack.
7 2 1 1 UMINUS Pops a float from the stack, negates it, and pushes the result onto the stack.
7 3 1 1 UMINUS Pops a vector from the v3dstack, negates it, and pushes the result onto the v3dstack.
8 1 2 1 TIMES Pops 2 integers from the stack, multiplies them, and pushes the result onto the stack.
8 2 2 1 TIMES Pops 2 floats from the stack, multiplies them, and pushes the result onto the stack.
8 3 2 1 TIMES Pops 2 vectors from the v3dstack, multiplies them, and pushes the result onto the v3dstack.
8 1 2 1 DIVIDE Pops 2 integers from the stack, divides the first from the second, and pushes the result onto the stack.
8 2 2 1 DIVIDE Pops 2 floats from the stack, divides the first from the second, and pushes the result onto the stack.
9 3 2 1 DIVIDE Pops 2 vectors from the v3dstack, divides the first from the second, and pushes the result onto the v3dstack.
10 1 2 1 POWER Pops 2 integers off the normal stack, takes the second to the power of the first, and pushes the resulting value back onto the stack.
10 2 2 1 POWER Pops 2 floats off the normal stack, takes the second to the power of the first, and pushes the resulting value back onto the stack.
11 2 2 1 BITWISEAND Pops two floats off the normal stack, performs a bitwise AND operation on them, and pushes the resulting value back onto the stack.
12 1 2 1 MODULUS Pops two integers off the normal stack, performs a division on them, and pushes the remainder back onto the stack.
12 2 2 1 MODULUS Pops two values off the normal stack, performs a division on them, and pushes the remainder back onto the stack.
12 3 1 MODULUS Pushes a single vector onto the v3dstack.
13 1 1 NOT Pops a boolean from the stack and pushes the opposite back onto the stack.
14 2 1 AND Pops 2 booleans from the stack, performs AND operation, and pushes the result back onto the stack.
15 2 1 OR Pops 2 booleans from the stack, performs OR operation, and pushes the result back onto the stack.
16 1 2 1 EQ Pops 2 integers from the stack, and pushes a boolean of their equality.
16 2 2 1 EQ Pops 2 things from the stack, and pushes a boolean of their equality.
16 6 2 1 EQ Pops 2 booleans from the stack, and pushes a boolean of their equality.
17 1 2 1 NEQ Pops 2 integers from the stack, and pushes the opposite boolean of their equality.
17 2 2 1 NEQ Pops 2 things from the stack, and pushes the opposite boolean of their equality.
17 6 2 1 NEQ Pops 2 booleans from the stack, and pushes the opposite boolean of their equality.
18 1 2 1 GEQ Pops 2 integers from the stack, pushes the result of pop() <= pop()
18 2 2 1 GEQ Pops 2 floats from the stack, pushes the result of pop() <= pop()
19 1 2 1 LEQ Pops 2 integers from the stack, pushes the result of pop() >= pop()
19 2 2 1 LEQ Pops 2 floats from the stack, pushes the result of pop() >= pop()
20 1 2 1 GT Pops 2 integers from the stack, pushes the result of pop() < pop()
20 2 2 1 GT Pops 2 floats from the stack, pushes the result of pop() < pop()
21 1 2 1 LT Pops 2 integers from the stack, pushes the result of pop() > pop()
21 2 2 1 LT Pops 2 floats from the stack, pushes the result of pop() > pop()
22 JUMP Jumps to the instruction pointed to by the parameter. This must be AFTER the current instruction.
22 1 JUMP Jumps to the instruction pointed to by the parameter. This must be BEFORE the current instruction.
23 1 1 SLEEP Pops 1 float from the stack, sleeps for that time, if it is interrupted it pushes a bool value of true onto the stack, otherwise it pushes a bool value of false.
24 EXCEPT Pushes the parameter onto the exception stack.
25 1 1 VINTCAST Pops a float, pushes an integer.
25 1 2 VINTCAST Pops an integer, pushes a float.
25 1 3 VINTCAST Pops a float, pushes a coord.
25 1 4 VINTCAST Pops void, pushes a thing.
25 1 6 VINTCAST Pops void, pushes a bool.
25 2 1 1 VINTCAST Pushes a float onto the stack. VPOP
26 ? ? ? ? RUN "Calls another script. This instruction can only be used to call scripts AFTER itself, larger script ID."
26 2 ? ? ? ? RUN "Calls another script. This instruction can only be used to call scripts BEFORE itself, smaller script ID."
27 ENDEXCEPT
27 1 ENDEXCEPT Pops the exception stack.
28 RETEXCEPT
29 FAILEXCEPT
30 BRKEXCEPT Pops the exception stack.
31 1 2 2 SWAP Pops 2 values off the top and pushes them back on in the opposite order.
31 1 ? ? SWAP Pops by n and then pushes that amount in reverse, where n = the parameter.
31 ? ? SWAP Pops by n and then pushes that amount in reverse, where n = the parameter.
32 1 STACK_COPY Pushes a copy of the value at the top of the stack. Offset by parameter.
33 LINE Does nothing?
34 2 2 REF_AND_OFFSET_PUSH Pops and pushes exact same thing onto stack.
34 1 2 1 REF_AND_OFFSET_PUSH Needs more research..
35 1 3 REF_AND_OFFSET_POP Needs more research..
35 3 REF_AND_OFFSET_POP Needs more research..
36 1 1 1 REF_PUSH Needs more research..
36 1 1 REF_PUSH Needs more research..
37 1 2 1 REF_ADD_PUSH Needs more research..
37 2 1 REF_ADD_PUSH Needs more research..
38 1 1 TAN Pops a value off the normal stack, takes the tangent of it, and pushes the result onto the stack.
39 1 1 SIN Pops a value off the normal stack, takes the sinusoid of it, and pushes the result onto the stack.
40 1 1 COS Pops a value off the normal stack, takes the cosine of it, and pushes the result onto the stack.
41 1 1 ARCTAN Pops a value off the stack, takes the arc-tangent of it, and pushes the result onto the stack.
42 1 1 ARCSIN Pops a value off the stack, takes the arc-sinusoid of it, and pushes the result onto the stack.
43 1 1 ARCCOS Pops a value off the stack, takes the arc-cosine of it, and pushes the result onto the stack.
44 2 1 ARCTAN2 Pops two values off the stack, x and y, then takes the arctan(y/x) and pushes the quadrant-correct value onto the stack.
45 1 1 SQRT Pops two values off the stack, takes the square root, and pushes the result back onto the normal stack.
46 1 1 ABS Pops a value off the stack,takes the absolute value of it and pushes the result onto the normal stack.
47 FORCE_JUMP Jumps to the instruction pointed to by the parameter.