Difference between revisions of "VM instructions / opcodes"

From Final Fantasy XII Wiki
Jump to navigation Jump to search
m
m
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
 
|0x10
 
|0x10
 
|1
 
|1
 
|no
 
|no
 
|2
 
|2
|
+
|Shift left logical
 
|-
 
|-
|
+
|OPSRL
 
|0x11
 
|0x11
 
|1
 
|1
 
|no
 
|no
 
|2
 
|2
|
+
|Shift right logical
 
|-
 
|-
|
+
|OPADD
 
|0x12
 
|0x12
 
|1
 
|1
 
|no
 
|no
 
|2
 
|2
|
+
|Addition
 
|-
 
|-
|
+
|OPSUB
 
|0x13
 
|0x13
 
|1
 
|1
 
|no
 
|no
 
|2
 
|2
|
+
|Substraction
 
|-
 
|-
|
+
|OPMUL
 
|0x14
 
|0x14
 
|1
 
|1
 
|no
 
|no
 
|2
 
|2
|
+
|Multiplication
 
|-
 
|-
|
+
|OPDIV
 
|0x15
 
|0x15
 
|1
 
|1
 
|no
 
|no
 
|2
 
|2
|
+
|Division
 
|-
 
|-
|
+
|OPMOD
 
|0x16
 
|0x16
 
|1
 
|1
 
|no
 
|no
 
|2
 
|2
|
+
|Modulo
 
|-
 
|-
|
+
|OPNOT
 
|0x17
 
|0x17
 
|1
 
|1
 
|no
 
|no
|2
+
|1
|
+
|Logical negation
 
|-
 
|-
|
+
|OPBNOT
 
|0x18
 
|0x18
 
|1
 
|1
 
|no
 
|no
|2
+
|1
|
+
|Binary negation
 
|-
 
|-
|
+
|OPUMINUS
 
|0x19
 
|0x19
 
|1
 
|1
 
|no
 
|no
|2
+
|1
|
+
|Not used
 
|-
 
|-
|
+
|OPFIXADRS
 
|0x1a
 
|0x1a
 
|1
 
|1
 
|no
 
|no
|2
+
|1
|
+
|Not used
 
|}
 
|}
 
[[Category:Instructions]]
 
[[Category:Instructions]]
 
[[Category:VM]]
 
[[Category:VM]]
 
[[Category:General]]
 
[[Category:General]]

Revision as of 10:16, 15 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