User:SquidKid S/CHANS

From WiiBrew
Jump to navigation Jump to search

Most info here is taken from CHANS & the CHANS parser linked there.
When parameters are used from the stack ("..."), they are used in the order in which they were PUSHed, then removed from the stack.
Scripts may defined their own functions. When these are called, parameters are placed in the highest-numbered temporary variables (which are local to each function), in numeric order; for example, with three parameters, they are placed respectively in temporary variables 0xFFD, 0xFFE, and 0xFFF.

8-bit operations

Opcode Param Meaning
0x00 none return;
0x01 none return ACC;
0x02 u8 (number of params from stack) ACC = new ACC(...);
0x03 u16 (number of params from stack) ACC = {...};
0x04 none PUSH(ACC);
0x05 (?) 1 param from stack ACC = ...;
0x06 1 param from stack ACC = ... + ACC;
0x07 1 param from stack ACC = ... - ACC;
0x08 1 param from stack ACC = ... * ACC;
0x09 1 param from stack ACC = ... / ACC;
0x0A 1 param from stack ACC = ... % ACC;
0x0B 1 param from stack ACC = ... & ACC;
0x0C 1 param from stack ACC = ... | ACC;
0x0D 1 param from stack ACC = ... ^ ACC;
0x0E 1 param from stack ACC = ... << ACC;
0x0F 1 param from stack ACC = ... >> ACC;
0x10 1 param from stack ACC = ... == ACC;
0x11 1 param from stack ACC = ... != ACC;
0x12 1 param from stack ACC = ... < ACC;
0x13 1 param from stack ACC = ... > ACC;
0x14 1 param from stack ACC = ... <= ACC;
0x15 1 param from stack ACC = ... >= ACC;
0x17 none ACC = !ACC;
0x18 u8 (value) ACC = value;
0x19 u8 (value) ACC += value;
0x1A u8 (value) ACC -= value;
0x1B u8 (value) ACC *= value;
0x1C u8 (value) ACC /= value;
0x1D u8 (value) ACC %= value;
0x1E u8 (value) ACC &= value;
0x1F u8 (value) ACC |= value;
0x20 u8 (value) ACC ^= value;
0x21 u8 (value) ACC = ACC == value;
0x22 u8 (value) ACC = ACC != value;
0x23 u8 (value) ACC = ACC < value;
0x24 u8 (value) ACC = ACC > value;
0x25 u8 (value) ACC = ACC <= value;
0x26 u8 (value) ACC = ACC >= value;
0x27 u16 (value) ACC = value;
0x28 u32 (value) ACC = value;
0x29 (?) f32 (value) ACC = value;
0x2A f64 (value) ACC = value;
0x2B ??? /*???*/
0x2C u16 (index) ACC = table3[index]; /* were this an actual programming language (and I get the idea that Nintendo had one that they compiled into this bytecode), string literals would probably be written in the code. */
0x2D u8 (operation type) /* array operation; see below. */
0x2E ??? /*???*/
0x2F ??? /*???*/
0x30 u16 (id of func in table2), u8 (number of params from stack) ACC = ACC.func(...);
0x31 u8 (number of params from stack) ACC = ACC(...);
0x32 u16 (id of sym in table2) ACC = ACC.sym;
0x33 u16 (id of sym in table2), 1 param from stack ACC.sym = ...;
0x34 ??? /*???*/
0x35 ??? /*???*/
0x36 ??? /*???*/
0x37 ??? /*???*/
0x38 ??? /*???*/
0x39 ??? /*???*/
0x3A ??? /*???*/
0x3B ??? /*???*/
0x3C ??? /*???*/
0x3D ??? /*???*/
0x3E ??? /*???*/
0x3F ??? /*???*/

4-bit operations

Opcode Param Meaning
0x4 u12 (id of locsym in table4) ACC = locsym;
0x5 u12 (id of tempvar) ACC = tempvar;
0x6 u12 (id of locsym in table4) locsym = ACC;
0x7 u12 (id of tempvar) tempvar = ACC;
0x8 u12 (id of tempvar) /*???*/
0x9 ??? /*???*/
0xA s12 (position in bytes, 0 being the byte just after the command) if (!ACC) goto position; /* mostly used for if-like constructions. */
0xB ??? /*???*/
0xC (?) s12 (position in bytes, 0 being the byte just after the command) if (!ACC) goto position; /* same as 0xA, though rarer. */
0xD s12 (position in bytes, 0 being the byte just after the command) if (ACC) goto position; /* mostly used to continue a loop. */
0xE s12 (position in bytes, 0 being the byte just after the command) goto position; /* mostly used for else blocks, or to jump to the condition check in a loop before starting it. */
0xF u12 (id of tempvar) /*???*/

Array operations

Opcode Param Meaning
0x3E 1 param from stack ACC = ...[ACC];
0x3F 2 params, A and B, from stack A[ACC] = B;

Built-in types

Integer
Float
String
Array

Classes/types

NWC24
System
Layout
SaveData
Anim
TextWriter
Date
String

Games/channels

Mario Kart Channel
Mario Kart Wii