Difference between revisions of "VM instructions / opcodes"
Jump to navigation
Jump to search
(5 intermediate revisions by the same user not shown) | |||
Line 16: | Line 16: | ||
|Don't use. It causes eternal loop | |Don't use. It causes eternal loop | ||
|- | |- | ||
− | |LABEL | + | |[[LABEL (instruction)|LABEL]] |
|0x01 | |0x01 | ||
|0 | |0 | ||
Line 23: | Line 23: | ||
|Don't use. It causes eternal loop | |Don't use. It causes eternal loop | ||
|- | |- | ||
− | |TAG | + | |[[TAG (instruction)|TAG]] |
|0x02 | |0x02 | ||
|0 | |0 | ||
Line 30: | Line 30: | ||
|Don't use. It causes eternal loop | |Don't use. It causes eternal loop | ||
|- | |- | ||
− | |SYSHALT | + | |[[SYSHALT (instruction)|SYSHALT]] |
|0x03 | |0x03 | ||
|1 | |1 | ||
Line 37: | Line 37: | ||
| | | | ||
|- | |- | ||
− | |SYSTEM | + | |[[SYSTEM (instruction)|SYSTEM]] |
|0x04 | |0x04 | ||
|1 | |1 | ||
Line 44: | Line 44: | ||
| | | | ||
|- | |- | ||
− | |OPLOR | + | |[[OPLOR (instruction)|OPLOR]] |
|0x05 | |0x05 | ||
|1 | |1 | ||
Line 51: | Line 51: | ||
|Logical or | |Logical or | ||
|- | |- | ||
− | |OPLAND | + | |[[OPLAND (instruction)|OPLAND]] |
|0x06 | |0x06 | ||
|1 | |1 | ||
Line 58: | Line 58: | ||
|Logical and | |Logical and | ||
|- | |- | ||
− | |OPOR | + | |[[OPOR (instruction)|OPOR]] |
|0x07 | |0x07 | ||
|1 | |1 | ||
Line 65: | Line 65: | ||
|Binary or | |Binary or | ||
|- | |- | ||
− | |OPEOR | + | |[[OPEOR (instruction)|OPEOR]] |
|0x08 | |0x08 | ||
|1 | |1 | ||
Line 72: | Line 72: | ||
|Binary exclusive or | |Binary exclusive or | ||
|- | |- | ||
− | |OPAND | + | |[[OPAND (instruction)|OPAND]] |
|0x09 | |0x09 | ||
|1 | |1 | ||
Line 79: | Line 79: | ||
|Binary and | |Binary and | ||
|- | |- | ||
− | |OPEQ | + | |[[OPEQ (instruction)|OPEQ]] |
|0x0a | |0x0a | ||
|1 | |1 | ||
Line 86: | Line 86: | ||
|Compares whether two values on stack are equal | |Compares whether two values on stack are equal | ||
|- | |- | ||
− | |OPNE | + | |[[OPNE (instruction)|OPNE]] |
|0x0b | |0x0b | ||
|1 | |1 | ||
Line 93: | Line 93: | ||
|Compares whether two values on stack are not equal | |Compares whether two values on stack are not equal | ||
|- | |- | ||
− | |OPGT | + | |[[OPGT (instruction)|OPGT]] |
|0x0c | |0x0c | ||
|1 | |1 | ||
Line 100: | Line 100: | ||
|Compares whether second value on stack is greater than first | |Compares whether second value on stack is greater than first | ||
|- | |- | ||
− | |OPLS | + | |[[OPLS (instruction)|OPLS]] |
|0x0d | |0x0d | ||
|1 | |1 | ||
Line 107: | Line 107: | ||
|Compares whether second value on stack is less than first | |Compares whether second value on stack is less than first | ||
|- | |- | ||
− | |OPGTE | + | |[[OPGTE (instruction)|OPGTE]] |
|0x0e | |0x0e | ||
|1 | |1 | ||
Line 114: | Line 114: | ||
|Compares whether second value on stack is greater or equal to first | |Compares whether second value on stack is greater or equal to first | ||
|- | |- | ||
− | |OPLSE | + | |[[OPLSE (instruction)|OPLSE]] |
|0x0f | |0x0f | ||
|1 | |1 | ||
Line 121: | Line 121: | ||
|Compares whether second value on stack is less or equal to first | |Compares whether second value on stack is less or equal to first | ||
|- | |- | ||
− | |OPSLL | + | |[[OPSLL (instruction)|OPSLL]] |
|0x10 | |0x10 | ||
|1 | |1 | ||
Line 128: | Line 128: | ||
|Shift left logical | |Shift left logical | ||
|- | |- | ||
− | |OPSRL | + | |[[OPSRL (instruction)|OPSRL]] |
|0x11 | |0x11 | ||
|1 | |1 | ||
Line 135: | Line 135: | ||
|Shift right logical | |Shift right logical | ||
|- | |- | ||
− | |OPADD | + | |[[OPADD (instruction)|OPADD]] |
|0x12 | |0x12 | ||
|1 | |1 | ||
Line 142: | Line 142: | ||
|Addition | |Addition | ||
|- | |- | ||
− | |OPSUB | + | |[[OPSUB (instruction)|OPSUB]] |
|0x13 | |0x13 | ||
|1 | |1 | ||
Line 149: | Line 149: | ||
|Substraction | |Substraction | ||
|- | |- | ||
− | |OPMUL | + | |[[OPMUL (instruction)|OPMUL]] |
|0x14 | |0x14 | ||
|1 | |1 | ||
Line 156: | Line 156: | ||
|Multiplication | |Multiplication | ||
|- | |- | ||
− | |OPDIV | + | |[[OPDIV (instruction)|OPDIV]] |
|0x15 | |0x15 | ||
|1 | |1 | ||
Line 163: | Line 163: | ||
|Division | |Division | ||
|- | |- | ||
− | |OPMOD | + | |[[OPMOD (instruction)|OPMOD]] |
|0x16 | |0x16 | ||
|1 | |1 | ||
Line 170: | Line 170: | ||
|Modulo | |Modulo | ||
|- | |- | ||
− | |OPNOT | + | |[[OPNOT (instruction)|OPNOT]] |
|0x17 | |0x17 | ||
|1 | |1 | ||
Line 177: | Line 177: | ||
|Logical negation | |Logical negation | ||
|- | |- | ||
− | |OPBNOT | + | |[[OPBNOT (instruction)|OPBNOT]] |
|0x18 | |0x18 | ||
|1 | |1 | ||
Line 184: | Line 184: | ||
|Binary negation | |Binary negation | ||
|- | |- | ||
− | |OPUMINUS | + | |[[OPUMINUS (instruction)|OPUMINUS]] |
|0x19 | |0x19 | ||
|1 | |1 | ||
Line 191: | Line 191: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |OPFIXADRS | + | |[[OPFIXADRS (instruction)|OPFIXADRS]] |
|0x1a | |0x1a | ||
|1 | |1 | ||
Line 198: | Line 198: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |PUSHA | + | |[[PUSHA (instruction)|PUSHA]] |
|0x1b | |0x1b | ||
|1 | |1 | ||
Line 205: | Line 205: | ||
|Pushes contents of A register to stack | |Pushes contents of A register to stack | ||
|- | |- | ||
− | |POPA | + | |[[POPA (instruction)|POPA]] |
|0x1c | |0x1c | ||
|1 | |1 | ||
Line 212: | Line 212: | ||
|Pops stack into A register | |Pops stack into A register | ||
|- | |- | ||
− | |PUSHX | + | |[[PUSHX (instruction)|PUSHX]] |
|0x1d | |0x1d | ||
|1 | |1 | ||
Line 219: | Line 219: | ||
|Pushes contents of X register to stack | |Pushes contents of X register to stack | ||
|- | |- | ||
− | |PUSHY | + | |[[PUSHY (instruction)|PUSHY]] |
|0x1e | |0x1e | ||
|1 | |1 | ||
Line 226: | Line 226: | ||
|Pushes contents of Y register to stack | |Pushes contents of Y register to stack | ||
|- | |- | ||
− | |POPX | + | |[[POPX (instruction)|POPX]] |
|0x1f | |0x1f | ||
|1 | |1 | ||
Line 233: | Line 233: | ||
|Pops stack into X register | |Pops stack into X register | ||
|- | |- | ||
− | |POPY | + | |[[POPY (instruction)|POPY]] |
|0x20 | |0x20 | ||
|1 | |1 | ||
Line 240: | Line 240: | ||
|Pops stack into Y register | |Pops stack into Y register | ||
|- | |- | ||
− | |REQ | + | |[[REQ (instruction)|REQ]] |
|0x21 | |0x21 | ||
|1 | |1 | ||
Line 247: | Line 247: | ||
|Queue script for execution | |Queue script for execution | ||
|- | |- | ||
− | |FREQ | + | |[[FREQ (instruction)|FREQ]] |
|0x22 | |0x22 | ||
|1 | |1 | ||
Line 254: | Line 254: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |TREQ | + | |[[TREQ (instruction)|TREQ]] |
|0x23 | |0x23 | ||
|1 | |1 | ||
Line 261: | Line 261: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |REQSW | + | |[[REQSW (instruction)|REQSW]] |
|0x24 | |0x24 | ||
|1 | |1 | ||
Line 268: | Line 268: | ||
|Queue script for asynchronous execution and wait for it to finish. | |Queue script for asynchronous execution and wait for it to finish. | ||
|- | |- | ||
− | |FREQSW | + | |[[FREQSW (instruction)|FREQSW]] |
|0x25 | |0x25 | ||
|1 | |1 | ||
Line 275: | Line 275: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |TREQSW | + | |[[TREQSW (instruction)|TREQSW]] |
|0x26 | |0x26 | ||
|1 | |1 | ||
Line 282: | Line 282: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |REQEW | + | |[[REQEW (instruction)|REQEW]] |
|0x27 | |0x27 | ||
|1 | |1 | ||
Line 289: | Line 289: | ||
|Queue script for synchronous execution and wait for it to finish. | |Queue script for synchronous execution and wait for it to finish. | ||
|- | |- | ||
− | |FREQEW | + | |[[FREQEW (instruction)|FREQEW]] |
|0x28 | |0x28 | ||
|1 | |1 | ||
Line 296: | Line 296: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |TREQEW | + | |[[TREQEW (instruction)|TREQEW]] |
|0x29 | |0x29 | ||
|1 | |1 | ||
Line 303: | Line 303: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |PREQ | + | |[[PREQ (instruction)|PREQ]] |
|0x2a | |0x2a | ||
|1 | |1 | ||
Line 310: | Line 310: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |PREQSW | + | |[[PREQSW (instruction)|PREQSW]] |
|0x2b | |0x2b | ||
|1 | |1 | ||
Line 317: | Line 317: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |PREQEW | + | |[[PREQEW (instruction)|PREQEW]] |
|0x2c | |0x2c | ||
|1 | |1 | ||
Line 324: | Line 324: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |RET | + | |[[RET (instruction)|RET]] |
|0x2d | |0x2d | ||
|1 | |1 | ||
Line 331: | Line 331: | ||
|End function and return | |End function and return | ||
|- | |- | ||
− | |RETN | + | |[[RETN (instruction)|RETN]] |
|0x2e | |0x2e | ||
|1 | |1 | ||
Line 338: | Line 338: | ||
| | | | ||
|- | |- | ||
− | |RETT | + | |[[RETT (instruction)|RETT]] |
|0x2f | |0x2f | ||
|1 | |1 | ||
Line 345: | Line 345: | ||
| | | | ||
|- | |- | ||
− | |RETTN | + | |[[RETTN (instruction)|RETTN]] |
|0x30 | |0x30 | ||
|1 | |1 | ||
Line 352: | Line 352: | ||
| | | | ||
|- | |- | ||
− | |DRET | + | |[[DRET (instruction)|DRET]] |
|0x31 | |0x31 | ||
|1 | |1 | ||
Line 359: | Line 359: | ||
| | | | ||
|- | |- | ||
− | |REQWAIT | + | |[[REQWAIT (instruction)|REQWAIT]] |
|0x32 | |0x32 | ||
|1 | |1 | ||
Line 366: | Line 366: | ||
|Wait for a specified queued script to finish | |Wait for a specified queued script to finish | ||
|- | |- | ||
− | |PREQWAIT | + | |[[PREQWAIT (instruction)|PREQWAIT]] |
|0x33 | |0x33 | ||
|1 | |1 | ||
Line 373: | Line 373: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |REQCHG | + | |[[REQCHG (instruction)|REQCHG]] |
|0x34 | |0x34 | ||
|1 | |1 | ||
Line 380: | Line 380: | ||
| | | | ||
|- | |- | ||
− | |REQCANCEL | + | |[[REQCANCEL (instruction)|REQCANCEL]] |
|0x35 | |0x35 | ||
|1 | |1 | ||
Line 387: | Line 387: | ||
|Not used (see freqcancel) | |Not used (see freqcancel) | ||
|- | |- | ||
− | |POPI0 | + | |[[POPI0 (instruction)|POPI0]] |
|0x36 | |0x36 | ||
|1 | |1 | ||
Line 394: | Line 394: | ||
|Pops stack into I0 register | |Pops stack into I0 register | ||
|- | |- | ||
− | |POPI1 | + | |[[POPI1 (instruction)|POPI1]] |
|0x37 | |0x37 | ||
|1 | |1 | ||
Line 401: | Line 401: | ||
|Pops stack into I1 register | |Pops stack into I1 register | ||
|- | |- | ||
− | |POPI2 | + | |[[POPI2 (instruction)|POPI2]] |
|0x38 | |0x38 | ||
|1 | |1 | ||
Line 408: | Line 408: | ||
|Pops stack into I2 register | |Pops stack into I2 register | ||
|- | |- | ||
− | |POPI3 | + | |[[POPI3 (instruction)|POPI3]] |
|0x39 | |0x39 | ||
|1 | |1 | ||
Line 415: | Line 415: | ||
|Pops stack into I3 register | |Pops stack into I3 register | ||
|- | |- | ||
− | |POPF0 | + | |[[POPF0 (instruction)|POPF0]] |
|0x3a | |0x3a | ||
|1 | |1 | ||
Line 422: | Line 422: | ||
|Pops stack into F0 register | |Pops stack into F0 register | ||
|- | |- | ||
− | |POPF1 | + | |[[POPF1 (instruction)|POPF1]] |
|0x3b | |0x3b | ||
|1 | |1 | ||
Line 429: | Line 429: | ||
|Pops stack into F1 register | |Pops stack into F1 register | ||
|- | |- | ||
− | |POPF2 | + | |[[POPF2 (instruction)|POPF2]] |
|0x3c | |0x3c | ||
|1 | |1 | ||
Line 436: | Line 436: | ||
|Pops stack into F2 register | |Pops stack into F2 register | ||
|- | |- | ||
− | |POPF3 | + | |[[POPF3 (instruction)|POPF3]] |
|0x3d | |0x3d | ||
|1 | |1 | ||
Line 443: | Line 443: | ||
|Pops stack into F3 register | |Pops stack into F3 register | ||
|- | |- | ||
− | |PUSHI0 | + | |[[PUSHI0 (instruction)|PUSHI0]] |
|0x3e | |0x3e | ||
|1 | |1 | ||
Line 450: | Line 450: | ||
|Pushes I0 register onto stack | |Pushes I0 register onto stack | ||
|- | |- | ||
− | |PUSHI1 | + | |[[PUSHI1 (instruction)|PUSHI1]] |
|0x3f | |0x3f | ||
|1 | |1 | ||
Line 457: | Line 457: | ||
|Pushes I1 register onto stack | |Pushes I1 register onto stack | ||
|- | |- | ||
− | |PUSHI2 | + | |[[PUSHI2 (instruction)|PUSHI2]] |
|0x40 | |0x40 | ||
|1 | |1 | ||
Line 464: | Line 464: | ||
|Pushes I2 register onto stack | |Pushes I2 register onto stack | ||
|- | |- | ||
− | |PUSHI3 | + | |[[PUSHI3 (instruction)|PUSHI3]] |
|0x41 | |0x41 | ||
|1 | |1 | ||
Line 471: | Line 471: | ||
|Pushes I3 register onto stack | |Pushes I3 register onto stack | ||
|- | |- | ||
− | |PUSHF0 | + | |[[PUSHF0 (instruction)|PUSHF0]] |
|0x42 | |0x42 | ||
|1 | |1 | ||
Line 478: | Line 478: | ||
|Pushes F0 register onto stack | |Pushes F0 register onto stack | ||
|- | |- | ||
− | |PUSHF1 | + | |[[PUSHF1 (instruction)|PUSHF1]] |
|0x43 | |0x43 | ||
|1 | |1 | ||
Line 485: | Line 485: | ||
|Pushes F1 register onto stack | |Pushes F1 register onto stack | ||
|- | |- | ||
− | |PUSHF2 | + | |[[PUSHF2 (instruction)|PUSHF2]] |
|0x44 | |0x44 | ||
|1 | |1 | ||
Line 492: | Line 492: | ||
|Pushes F2 register onto stack | |Pushes F2 register onto stack | ||
|- | |- | ||
− | |PUSHF3 | + | |[[PUSHF3 (instruction)|PUSHF3]] |
|0x45 | |0x45 | ||
|1 | |1 | ||
Line 499: | Line 499: | ||
|Pushes F3 register onto stack | |Pushes F3 register onto stack | ||
|- | |- | ||
− | |DVAR | + | |[[DVAR (instruction)|DVAR]] |
|0x46 | |0x46 | ||
|1 | |1 | ||
Line 506: | Line 506: | ||
|Pops a variable from debug stack and puts on position specified as argument | |Pops a variable from debug stack and puts on position specified as argument | ||
|- | |- | ||
− | |LONGCODESTART | + | |[[LONGCODESTART (instruction)|LONGCODESTART]] |
|0x47 | |0x47 | ||
|1 | |1 | ||
Line 513: | Line 513: | ||
|Not used | |Not used | ||
|- | |- | ||
− | |PUSHV | + | |[[PUSHV (instruction)|PUSHV]] |
|0x48 | |0x48 | ||
|3 | |3 | ||
Line 520: | Line 520: | ||
|Push variable value onto stack | |Push variable value onto stack | ||
|- | |- | ||
− | |POPV | + | |[[POPV (instruction)|POPV]] |
|0x49 | |0x49 | ||
|3 | |3 | ||
Line 527: | Line 527: | ||
|Pops stack into variable | |Pops stack into variable | ||
|- | |- | ||
− | |PUSHDBG | + | |[[PUSHDBG (instruction)|PUSHDBG]] |
|0x4a | |0x4a | ||
|3 | |3 | ||
Line 534: | Line 534: | ||
|Pushes variable onto debug stack | |Pushes variable onto debug stack | ||
|- | |- | ||
− | |PUSHP | + | |[[PUSHP (instruction)|PUSHP]] |
|0x4b | |0x4b | ||
|3 | |3 | ||
Line 541: | Line 541: | ||
|Pushes [[General Vritual Machine architecture#Pointers and references|pointer]] to a variable onto stack | |Pushes [[General Vritual Machine architecture#Pointers and references|pointer]] to a variable onto stack | ||
|- | |- | ||
− | |PUSHTAG | + | |[[PUSHTAG (instruction)|PUSHTAG]] |
|0x4c | |0x4c | ||
|2 | |2 | ||
Line 548: | Line 548: | ||
|Not used (pushes script number) | |Not used (pushes script number) | ||
|- | |- | ||
− | |PUSHACT | + | |[[PUSHACT (instruction)|PUSHACT]] |
|0x4d | |0x4d | ||
|3 | |3 | ||
Line 555: | Line 555: | ||
|Not used (pushes function number) | |Not used (pushes function number) | ||
|- | |- | ||
− | |PUSHI | + | |[[PUSHI (instruction)|PUSHI]] |
|0x4e | |0x4e | ||
|3 | |3 | ||
Line 562: | Line 562: | ||
|Pushes integer from integer table onto stack | |Pushes integer from integer table onto stack | ||
|- | |- | ||
− | |PUSHII | + | |[[PUSHII (instruction)|PUSHII]] |
|0x4f | |0x4f | ||
|3 | |3 | ||
Line 569: | Line 569: | ||
|Pushes signed 16bit integer immediate onto stack | |Pushes signed 16bit integer immediate onto stack | ||
|- | |- | ||
− | |PUSHF | + | |[[PUSHF (instruction)|PUSHF]] |
|0x50 | |0x50 | ||
|3 | |3 | ||
Line 576: | Line 576: | ||
|Pushes float from float table onto stack | |Pushes float from float table onto stack | ||
|- | |- | ||
− | |JMP | + | |[[JMP (instruction)|JMP]] |
|0x51 | |0x51 | ||
|3 | |3 | ||
Line 583: | Line 583: | ||
|Unconditionally jumps to an offset specified by an index in script's jump table | |Unconditionally jumps to an offset specified by an index in script's jump table | ||
|- | |- | ||
− | |POPCMPYEQJMP | + | |[[POPCMPYEQJMP (instruction)|POPCMPYEQJMP]] |
|0x52 | |0x52 | ||
|3 | |3 | ||
Line 590: | Line 590: | ||
|Pops stack and jumps if equal to Y register | |Pops stack and jumps if equal to Y register | ||
|- | |- | ||
− | |POPCMPYLOWJMP | + | |[[POPCMPYLOWJMP (instruction)|POPCMPYLOWJMP]] |
|0x53 | |0x53 | ||
|3 | |3 | ||
Line 597: | Line 597: | ||
|Pops stack and jumps if less than Y register | |Pops stack and jumps if less than Y register | ||
|- | |- | ||
− | |POPCMPYLOWEQJMP | + | |[[POPCMPYLOWEQJMP (instruction)|POPCMPYLOWEQJMP]] |
|0x54 | |0x54 | ||
|3 | |3 | ||
Line 604: | Line 604: | ||
|Pops stack and jumps if less or equal to Y register | |Pops stack and jumps if less or equal to Y register | ||
|- | |- | ||
− | |POPCMPYHIGHJMP | + | |[[POPCMPYHIGHJMP (instruction)|POPCMPYHIGHJMP]] |
|0x55 | |0x55 | ||
|3 | |3 | ||
Line 611: | Line 611: | ||
|Pops stack and jumps if greater than Y register | |Pops stack and jumps if greater than Y register | ||
|- | |- | ||
− | |POPCMPYHIGHEQJMP | + | |[[POPCMPYHIGHEQJMP (instruction)|POPCMPYHIGHEQJMP]] |
|0x56 | |0x56 | ||
|3 | |3 | ||
Line 618: | Line 618: | ||
|Pops stack and jumps if greater or equal to Y register | |Pops stack and jumps if greater or equal to Y register | ||
|- | |- | ||
− | |POP2CMPYBTWNJMP | + | |[[POP2CMPYBTWNJMP (instruction)|POP2CMPYBTWNJMP]] |
|0x57 | |0x57 | ||
|3 | |3 | ||
Line 625: | Line 625: | ||
|Pops two values from stack and jumps if Y register's value is between (including) these values | |Pops two values from stack and jumps if Y register's value is between (including) these values | ||
|- | |- | ||
− | |CALL | + | |[[CALL (instruction)|CALL]] |
|0x58 | |0x58 | ||
|3 | |3 | ||
Line 632: | Line 632: | ||
|Calls external function (by specifying its number in VM's call table). Function's return value is left on stack. | |Calls external function (by specifying its number in VM's call table). Function's return value is left on stack. | ||
|- | |- | ||
− | |CALLACT | + | |[[CALLACT (instruction)|CALLACT]] |
|0x59 | |0x59 | ||
|3 | |3 | ||
Line 639: | Line 639: | ||
|Calls external function (by specifying its number in VM's call table) in context of another script (pops its number from stack). Function's return value is left on stack. | |Calls external function (by specifying its number in VM's call table) in context of another script (pops its number from stack). Function's return value is left on stack. | ||
|- | |- | ||
− | |POPXJMP | + | |[[POPXJMP (instruction)|POPXJMP]] |
|0x5a | |0x5a | ||
|3 | |3 | ||
Line 646: | Line 646: | ||
|Pops stack into X register and jumps unconditionally | |Pops stack into X register and jumps unconditionally | ||
|- | |- | ||
− | |POPXCJMP | + | |[[POPXCJMP (instruction)|POPXCJMP]] |
|0x5b | |0x5b | ||
|3 | |3 | ||
Line 653: | Line 653: | ||
|Pops stack into X register and jumps if true<ref name="bool">values on stack evaluate to true if they're greater than zero and to false otherwise</ref> | |Pops stack into X register and jumps if true<ref name="bool">values on stack evaluate to true if they're greater than zero and to false otherwise</ref> | ||
|- | |- | ||
− | |POPXNCJMP | + | |[[POPXNCJMP (instruction)|POPXNCJMP]] |
|0x5c | |0x5c | ||
|3 | |3 | ||
Line 660: | Line 660: | ||
|Pops stack into X register and jumps if false<ref name="bool" /> | |Pops stack into X register and jumps if false<ref name="bool" /> | ||
|- | |- | ||
− | |CALLPOPA | + | |[[CALLPOPA (instruction)|CALLPOPA]] |
|0x5d | |0x5d | ||
|3 | |3 | ||
Line 667: | Line 667: | ||
|Calls external function (by specifying its number in VM's call table). Function's return value is popped into A register. | |Calls external function (by specifying its number in VM's call table). Function's return value is popped into A register. | ||
|- | |- | ||
− | |CALLACTPOPA | + | |[[CALLACTPOPA (instruction)|CALLACTPOPA]] |
|0x5e | |0x5e | ||
|3 | |3 | ||
Line 674: | Line 674: | ||
|Calls external function (by specifying its number in VM's call table) in context of another script (pops its number from stack). Function's return value is popped into A register. | |Calls external function (by specifying its number in VM's call table) in context of another script (pops its number from stack). Function's return value is popped into A register. | ||
|- | |- | ||
− | |REQALL | + | |[[REQALL (instruction)|REQALL]] |
|0x5f | |0x5f | ||
|3 | |3 | ||
Line 681: | Line 681: | ||
|Queues all scripts within REQ table specified by an immediate for execution. | |Queues all scripts within REQ table specified by an immediate for execution. | ||
|- | |- | ||
− | |JMPINTERNAL | + | |[[JMPINTERNAL (instruction)|JMPINTERNAL]] |
|0x60 | |0x60 | ||
|3 | |3 | ||
Line 688: | Line 688: | ||
|Not used (normal jumps cover entire script) | |Not used (normal jumps cover entire script) | ||
|- | |- | ||
− | |REQWAITALL | + | |[[REQWAITALL (instruction)|REQWAITALL]] |
|0x61 | |0x61 | ||
|3 | |3 | ||
Line 695: | Line 695: | ||
|Waits for all scripts within REQ table specified by an immediate to finish. | |Waits for all scripts within REQ table specified by an immediate to finish. | ||
|- | |- | ||
− | |INCINITTAG | + | |[[INCINITTAG (instruction)|INCINITTAG]] |
|0x62 | |0x62 | ||
|3 | |3 | ||
Line 702: | Line 702: | ||
| | | | ||
|- | |- | ||
− | |REQIALL | + | |[[REQIALL (instruction)|REQIALL]] |
|0x63 | |0x63 | ||
|3 | |3 | ||
Line 712: | Line 712: | ||
<references /> | <references /> | ||
[[Category:Instructions]] | [[Category:Instructions]] | ||
− | |||
− |
Latest revision as of 08:14, 24 July 2019
Final Fantasy XII VM supports 100 known opcodes. There are three types of instructions. Instructions with an immediate, which are 3 bytes long, instructions without immediate, which are 1 byte long and special instructions like NOP and LABEL that have a defined size of zero and thus can't be used, because it causes the VM to loop indefinitely. These are probably used only by compiler and never put in the code itself.
Name | Opcode | Size | Immediate | Arguments | Description |
---|---|---|---|---|---|
NOP | 0x00 | 0 | no | 0 | Don't use. It causes eternal loop |
LABEL | 0x01 | 0 | no | 0 | Don't use. It causes eternal loop |
TAG | 0x02 | 0 | no | 0 | Don't use. It causes eternal loop |
SYSHALT | 0x03 | 1 | no | 0 | |
SYSTEM | 0x04 | 1 | no | 1 | |
OPLOR | 0x05 | 1 | no | 2 | Logical or |
OPLAND | 0x06 | 1 | no | 2 | Logical and |
OPOR | 0x07 | 1 | no | 2 | Binary or |
OPEOR | 0x08 | 1 | no | 2 | Binary exclusive or |
OPAND | 0x09 | 1 | no | 2 | Binary and |
OPEQ | 0x0a | 1 | no | 2 | Compares whether two values on stack are equal |
OPNE | 0x0b | 1 | no | 2 | Compares whether two values on stack are not equal |
OPGT | 0x0c | 1 | no | 2 | Compares whether second value on stack is greater than first |
OPLS | 0x0d | 1 | no | 2 | Compares whether second value on stack is less than first |
OPGTE | 0x0e | 1 | no | 2 | Compares whether second value on stack is greater or equal to first |
OPLSE | 0x0f | 1 | no | 2 | Compares whether second value on stack is less or equal to first |
OPSLL | 0x10 | 1 | no | 2 | Shift left logical |
OPSRL | 0x11 | 1 | no | 2 | Shift right logical |
OPADD | 0x12 | 1 | no | 2 | Addition |
OPSUB | 0x13 | 1 | no | 2 | Substraction |
OPMUL | 0x14 | 1 | no | 2 | Multiplication |
OPDIV | 0x15 | 1 | no | 2 | Division |
OPMOD | 0x16 | 1 | no | 2 | Modulo |
OPNOT | 0x17 | 1 | no | 1 | Logical negation |
OPBNOT | 0x18 | 1 | no | 1 | Binary negation |
OPUMINUS | 0x19 | 1 | no | 1 | Not used |
OPFIXADRS | 0x1a | 1 | no | 1 | Not used |
PUSHA | 0x1b | 1 | no | 0 | Pushes contents of A register to stack |
POPA | 0x1c | 1 | no | 0 | Pops stack into A register |
PUSHX | 0x1d | 1 | no | 0 | Pushes contents of X register to stack |
PUSHY | 0x1e | 1 | no | 0 | Pushes contents of Y register to stack |
POPX | 0x1f | 1 | no | 0 | Pops stack into X register |
POPY | 0x20 | 1 | no | 0 | Pops stack into Y register |
REQ | 0x21 | 1 | no | 3 | Queue script for execution |
FREQ | 0x22 | 1 | no | 3 | Not used |
TREQ | 0x23 | 1 | no | 3 | Not used |
REQSW | 0x24 | 1 | no | 3 | Queue script for asynchronous execution and wait for it to finish. |
FREQSW | 0x25 | 1 | no | 3 | Not used |
TREQSW | 0x26 | 1 | no | 3 | Not used |
REQEW | 0x27 | 1 | no | 3 | Queue script for synchronous execution and wait for it to finish. |
FREQEW | 0x28 | 1 | no | 3 | Not used |
TREQEW | 0x29 | 1 | no | 3 | Not used |
PREQ | 0x2a | 1 | no | 3 | Not used |
PREQSW | 0x2b | 1 | no | 3 | Not used |
PREQEW | 0x2c | 1 | no | 3 | Not used |
RET | 0x2d | 1 | no | 0 | End function and return |
RETN | 0x2e | 1 | no | 0 | |
RETT | 0x2f | 1 | no | 0 | |
RETTN | 0x30 | 1 | no | 0 | |
DRET | 0x31 | 1 | no | 0 | |
REQWAIT | 0x32 | 1 | no | 2 | Wait for a specified queued script to finish |
PREQWAIT | 0x33 | 1 | no | 2 | Not used |
REQCHG | 0x34 | 1 | no | 2 | |
REQCANCEL | 0x35 | 1 | no | 2 | Not used (see freqcancel) |
POPI0 | 0x36 | 1 | no | 0 | Pops stack into I0 register |
POPI1 | 0x37 | 1 | no | 0 | Pops stack into I1 register |
POPI2 | 0x38 | 1 | no | 0 | Pops stack into I2 register |
POPI3 | 0x39 | 1 | no | 0 | Pops stack into I3 register |
POPF0 | 0x3a | 1 | no | 0 | Pops stack into F0 register |
POPF1 | 0x3b | 1 | no | 0 | Pops stack into F1 register |
POPF2 | 0x3c | 1 | no | 0 | Pops stack into F2 register |
POPF3 | 0x3d | 1 | no | 0 | Pops stack into F3 register |
PUSHI0 | 0x3e | 1 | no | 0 | Pushes I0 register onto stack |
PUSHI1 | 0x3f | 1 | no | 0 | Pushes I1 register onto stack |
PUSHI2 | 0x40 | 1 | no | 0 | Pushes I2 register onto stack |
PUSHI3 | 0x41 | 1 | no | 0 | Pushes I3 register onto stack |
PUSHF0 | 0x42 | 1 | no | 0 | Pushes F0 register onto stack |
PUSHF1 | 0x43 | 1 | no | 0 | Pushes F1 register onto stack |
PUSHF2 | 0x44 | 1 | no | 0 | Pushes F2 register onto stack |
PUSHF3 | 0x45 | 1 | no | 0 | Pushes F3 register onto stack |
DVAR | 0x46 | 1 | no | 2 | Pops a variable from debug stack and puts on position specified as argument |
LONGCODESTART | 0x47 | 1 | no | 0 | Not used |
PUSHV | 0x48 | 3 | yes | 0+dimensions | Push variable value onto stack |
POPV | 0x49 | 3 | yes | 0+dimensions | Pops stack into variable |
PUSHDBG | 0x4a | 3 | yes | 0+dimensions | Pushes variable onto debug stack |
PUSHP | 0x4b | 3 | yes | 0+dimensions | Pushes pointer to a variable onto stack |
PUSHTAG | 0x4c | 2 | yes | 0+dimensions | Not used (pushes script number) |
PUSHACT | 0x4d | 3 | yes | 0+dimensions | Not used (pushes function number) |
PUSHI | 0x4e | 3 | yes | 0 | Pushes integer from integer table onto stack |
PUSHII | 0x4f | 3 | yes | 0 | Pushes signed 16bit integer immediate onto stack |
PUSHF | 0x50 | 3 | yes | 0 | Pushes float from float table onto stack |
JMP | 0x51 | 3 | yes | 0 | Unconditionally jumps to an offset specified by an index in script's jump table |
POPCMPYEQJMP | 0x52 | 3 | yes | 1 | Pops stack and jumps if equal to Y register |
POPCMPYLOWJMP | 0x53 | 3 | yes | 1 | Pops stack and jumps if less than Y register |
POPCMPYLOWEQJMP | 0x54 | 3 | yes | 1 | Pops stack and jumps if less or equal to Y register |
POPCMPYHIGHJMP | 0x55 | 3 | yes | 1 | Pops stack and jumps if greater than Y register |
POPCMPYHIGHEQJMP | 0x56 | 3 | yes | 1 | Pops stack and jumps if greater or equal to Y register |
POP2CMPYBTWNJMP | 0x57 | 3 | yes | 2 | Pops two values from stack and jumps if Y register's value is between (including) these values |
CALL | 0x58 | 3 | yes | 0+args | Calls external function (by specifying its number in VM's call table). Function's return value is left on stack. |
CALLACT | 0x59 | 3 | yes | 1+args | Calls external function (by specifying its number in VM's call table) in context of another script (pops its number from stack). Function's return value is left on stack. |
POPXJMP | 0x5a | 3 | yes | 1 | Pops stack into X register and jumps unconditionally |
POPXCJMP | 0x5b | 3 | yes | 1 | Pops stack into X register and jumps if true[1] |
POPXNCJMP | 0x5c | 3 | yes | 1 | Pops stack into X register and jumps if false[1] |
CALLPOPA | 0x5d | 3 | yes | 0+args | Calls external function (by specifying its number in VM's call table). Function's return value is popped into A register. |
CALLACTPOPA | 0x5e | 3 | yes | 1+args | Calls external function (by specifying its number in VM's call table) in context of another script (pops its number from stack). Function's return value is popped into A register. |
REQALL | 0x5f | 3 | yes | 0 | Queues all scripts within REQ table specified by an immediate for execution. |
JMPINTERNAL | 0x60 | 3 | yes | 0 | Not used (normal jumps cover entire script) |
REQWAITALL | 0x61 | 3 | yes | 0 | Waits for all scripts within REQ table specified by an immediate to finish. |
INCINITTAG | 0x62 | 3 | yes | 0 | |
REQIALL | 0x63 | 3 | yes | 0 | Waits for all scripts within REQ table specified by an immediate to finish. |