diff --git a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java index f5e8762..386bf57 100644 --- a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java +++ b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java @@ -15,6 +15,7 @@ import org.jcnc.snow.vm.commands.bitwise.long64.LOrCommand; import org.jcnc.snow.vm.commands.bitwise.long64.LXorCommand; import org.jcnc.snow.vm.commands.control.all.JumpCommand; import org.jcnc.snow.vm.commands.control.int32.*; +import org.jcnc.snow.vm.commands.control.long64.*; import org.jcnc.snow.vm.commands.function.CallCommand; import org.jcnc.snow.vm.commands.function.RetCommand; import org.jcnc.snow.vm.commands.memory.all.MovCommand; @@ -47,88 +48,102 @@ import org.jcnc.snow.vm.module.LocalVariableStore; *

Each opcode represents a specific operation executed by the virtual machine.

*/ public class VMOpCode { - // region 1. Arithmetic Operations (1–100) - // region 1.1 int32 (0-9) + + // region Byte8 (0x0000-0x001F) /** - * I_ADD Opcode: Represents the int32 addition operation in the virtual machine. - *

This opcode is implemented by the {@link IAddCommand} class, which defines its specific execution logic.

+ * B_ADD Opcode: Represents the byte8 addition operation in the virtual machine. + *

This opcode is implemented by the {@link BAddCommand} class, which defines its specific execution logic.

* *

Execution Steps:

*
    - *
  1. Pops the top two int32 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the addition operation on these two int32s.
  4. + *
  5. Pops the top two byte8 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  6. + *
  7. Performs the addition operation on these two byte8 values.
  8. *
  9. Pushes the result of the addition back onto the operand stack for later instructions to use.
  10. *
* *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic int32 addition tasks.

+ * primarily used to handle basic byte8 addition tasks.

*/ - public static final int I_ADD = 0; + public static final int B_ADD = 0x0000; /** - * I_SUB Opcode: Represents the int32 subtraction operation in the virtual machine. - *

This opcode is implemented by the {@link ISubCommand} class, which defines its specific execution logic.

+ * B_SUB Opcode: Represents the byte8 subtraction operation in the virtual machine. + *

This opcode is implemented by the {@link BSubCommand} class, which defines its specific execution logic.

* *

Execution Steps:

*
    - *
  1. Pops the top two int32 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
  2. + *
  3. Pops the top two byte8 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
  4. *
  5. Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
  6. *
  7. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
  8. *
* *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic int32 subtraction tasks.

+ * primarily used to handle basic byte8 subtraction tasks.

*/ - public static final int I_SUB = 1; + public static final int B_SUB = 0x0001; /** - * I_MUL Opcode: Represents the int32 multiplication operation in the virtual machine. - *

This opcode is implemented by the {@link IMulCommand} class, which defines its specific execution logic.

+ * B_MUL Opcode: Represents the byte8 multiplication operation in the virtual machine. + *

This opcode is implemented by the {@link BMulCommand} class, which defines its specific execution logic.

* *

Execution Steps:

*
    - *
  1. Pops the top two int32 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the multiplication operation on these two int32s (i.e., firstOperand * secondOperand).
  4. + *
  5. Pops the top two byte8 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  6. + *
  7. Performs the multiplication operation on these two byte8 values (i.e., firstOperand * secondOperand).
  8. *
  9. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
  10. *
* *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic int32 multiplication tasks.

+ * primarily used to handle basic byte8 multiplication tasks.

*/ - public static final int I_MUL = 2; + public static final int B_MUL = 0x0002; /** - * I_DIV Opcode: Represents the int32 division operation in the virtual machine. - *

This opcode is implemented by the {@link IDivCommand} class, which defines its specific execution logic.

+ * B_DIV Opcode: Represents the byte8 division operation in the virtual machine. + *

This opcode is implemented by the {@link BDivCommand} class, which defines its specific execution logic.

* *

Execution Steps:

*
    - *
  1. Pops the top two int32 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. + *
  3. Pops the top two byte8 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  4. *
  5. Performs the division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
  6. *
  7. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  8. *
  9. Pushes the result of the division back onto the operand stack for later instructions to use.
  10. *
* *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic int32 division tasks.

+ * primarily used to handle basic byte8 division tasks.

*/ - public static final int I_DIV = 3; + public static final int B_DIV = 0x0003; /** - * I_MOD Opcode: Represents the int32 modulus (remainder) operation in the virtual machine. - *

This opcode is implemented by the {@link IModCommand} class, which defines its specific execution logic.

+ * B_MOD Opcode: Represents the byte8 modulus (remainder) operation in the virtual machine. + *

This opcode is implemented by the {@link BModCommand} class, which defines its specific execution logic.

* *

Execution Steps:

*
    - *
  1. Pops the top two int32 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. + *
  3. Pops the top two byte8 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  4. *
  5. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
  6. *
  7. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  8. *
  9. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
  10. *
* *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic int32 modulus (remainder) tasks.

+ * primarily used to handle basic byte8 modulus (remainder) tasks.

*/ - public static final int I_MOD = 4; + public static final int B_MOD = 0x0004; /** - * I_INC Opcode: Represents the int32 increment operation for a local variable in the virtual machine. - *

This opcode is implemented by the {@link IIncCommand} class, which defines its specific execution logic.

+ * B_NEG Opcode: Represents the byte8 negation operation in the virtual machine. + *

This opcode is implemented by the {@link BNegCommand} class, which defines its specific execution logic.

+ * + *

Execution Steps:

+ *
    + *
  1. Pops the top byte8 value from the operand stack.
  2. + *
  3. Performs the negation of the popped value (i.e., -value).
  4. + *
  5. Pushes the negated result back onto the operand stack for later instructions to use.
  6. + *
+ * + *

This opcode is typically used to negate a byte8 value, making it a fundamental operation for arithmetic logic within the virtual machine.

+ */ + public static final int B_NEG = 0x0005; + /** + * B_INC Opcode: Represents the byte8 increment operation for a local variable in the virtual machine. + *

This opcode is implemented by the {@link BIncCommand} class, which defines its specific execution logic.

* *

Execution Steps:

*
    @@ -140,152 +155,84 @@ public class VMOpCode { *
  1. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
  2. *
* - *

This opcode is particularly useful for optimizing scenarios where a local variable, such as a counter or loop index, is frequently incremented.

+ *

This opcode is particularly useful for optimizing scenarios where a local `byte8` variable, such as a counter or loop index, is frequently incremented.

*/ - public static final int I_INC = 5; + public static final int B_INC = 0x0006; + + public static final int B_AND = 0x0007; + public static final int B_OR = 0x0008; + public static final int B_XOR = 0x0009; + /** - * I_NEG Opcode: Represents the int32 negation operation in the virtual machine. - *

This opcode is implemented by the {@link INegCommand} class, which defines its specific execution logic.

+ * B_PUSH Opcode: Represents a stack operation that pushes a byte8 value onto the operand stack. + *

This opcode is implemented by the {@link BPushCommand} class, which defines its specific execution logic.

* *

Execution Steps:

*
    - *
  1. Pops the top int32 value from the operand stack.
  2. - *
  3. Performs the negation of the popped value (i.e., -value).
  4. - *
  5. Pushes the negated result back onto the operand stack for later instructions to use.
  6. + *
  7. Parses the byte8 value from the instruction parameters.
  8. + *
  9. Pushes the parsed byte8 value onto the operand stack.
  10. + *
  11. Increments the program counter (PC) to proceed with the next sequential instruction.
  12. *
* - *

This opcode is typically used to negate an int32 value, making it a fundamental operation for arithmetic logic within the virtual machine.

+ *

This opcode is commonly used for:

+ * */ - public static final int I_NEG = 6; + public static final int B_PUSH = 0x000A; + /** + * B_LOAD Opcode: Represents a load operation that retrieves a byte8 value from the local variable store and pushes it onto the operand stack. + *

This opcode is implemented by the {@link BLoadCommand} class, which defines its specific execution logic.

+ * + *

Execution Steps:

+ *
    + *
  1. Retrieves the index for the local variable from the instruction parameters.
  2. + *
  3. Retrieves the corresponding value from the local variable store of the current method frame.
  4. + *
  5. Pushes the retrieved value onto the operand stack for subsequent operations.
  6. + *
  7. Increments the program counter (PC) to proceed with the next sequential instruction.
  8. + *
+ * + *

This opcode is commonly used for:

+ * + */ + public static final int B_LOAD = 0x000B; + /** + * B_STORE Opcode: Represents a store operation that stores a byte8 value from the operand stack into the local variable store. + *

This opcode is implemented by the {@link BStoreCommand} class, which defines its specific execution logic.

+ * + *

Execution Steps:

+ *
    + *
  1. Retrieves the index for the local variable from the instruction parameters.
  2. + *
  3. Pops a byte8 value from the operand stack.
  4. + *
  5. Stores the value into the local variable store at the specified index of the current method frame.
  6. + *
  7. Increments the program counter (PC) to proceed with the next sequential instruction.
  8. + *
+ * + *

This opcode is commonly used for:

+ * + */ + public static final int B_STORE = 0x000C; + + public static final int B_CE = 0x000D; + public static final int B_CNE = 0x000E; + public static final int B_CG = 0x000F; + public static final int B_CGE = 0x0010; + public static final int B_CL = 0x0011; + public static final int B_CLE = 0x0012; // endregion - // region 1.2 long64 (10-19) - /** - * L_ADD Opcode: Represents the long64 addition operation in the virtual machine. - *

This opcode is implemented by the {@link LAddCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two long64 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the addition operation on these two long64s.
  4. - *
  5. Pushes the result of the addition back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic long64 addition tasks.

- */ - public static final int L_ADD = 10; - /** - * L_SUB Opcode: Represents the long64 subtraction operation in the virtual machine. - *

This opcode is implemented by the {@link LSubCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two long64 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
  2. - *
  3. Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
  4. - *
  5. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic long64 subtraction tasks.

- */ - public static final int L_SUB = 11; - /** - * L_MUL Opcode: Represents the long64 multiplication operation in the virtual machine. - *

This opcode is implemented by the {@link LMulCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two long64 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the multiplication operation on these two long64s (i.e., firstOperand * secondOperand).
  4. - *
  5. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic long64 multiplication tasks.

- */ - public static final int L_MUL = 12; - /** - * L_DIV Opcode: Represents the long64 division operation in the virtual machine. - *

This opcode is implemented by the {@link LDivCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two long64 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. - *
  3. Performs the division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
  4. - *
  5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  6. - *
  7. Pushes the result of the division back onto the operand stack for later instructions to use.
  8. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic long64 division tasks.

- */ - public static final int L_DIV = 13; - /** - * L_MOD Opcode: Represents the long64 modulus (remainder) operation in the virtual machine. - *

This opcode is implemented by the {@link LModCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two long64 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. - *
  3. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
  4. - *
  5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  6. - *
  7. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
  8. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic long64 modulus (remainder) tasks.

- */ - public static final int L_MOD = 14; - /** - * L_INC Opcode: Represents the long64 increment operation for a local variable in the virtual machine. - *

This opcode is implemented by the {@link LIncCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Retrieves the index of the local variable and the increment value from the instruction parameters.
  2. - *
  3. Gets the current value of the local variable at the specified index from the local variable store.
  4. - *
  5. Increments the local variable's value by the specified increment (i.e., - * localVariables[index] += increment).
  6. - *
  7. Updates the local variable store with the new incremented value.
  8. - *
  9. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
  10. - *
- * - *

This opcode is particularly useful for optimizing scenarios where a local `long64` variable, such as a counter or loop index, is frequently incremented.

- */ - public static final int L_INC = 15; - /** - * L_NEG Opcode: Represents the long64 negation operation in the virtual machine. - *

This opcode is implemented by the {@link LNegCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top long64 value from the operand stack.
  2. - *
  3. Performs the negation of the popped value (i.e., -value).
  4. - *
  5. Pushes the negated result back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is typically used to negate a long64 value, making it a fundamental operation for arithmetic logic within the virtual machine.

- */ - public static final int L_NEG = 16; - // endregion - - // region 1.3 short16 (20-29) - /** - * S_ADD Opcode: Represents the short16 addition operation in the virtual machine. - *

This opcode is implemented by the {@link SAddCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two short16 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the addition operation on these two short16 values.
  4. - *
  5. Pushes the result of the addition back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic short16 addition tasks.

- */ - public static final int S_ADD = 20; + // region Short16 (0x0020-0x003F) + public static final int S_ADD = 0x0020; /** * S_SUB Opcode: Represents the short16 subtraction operation in the virtual machine. *

This opcode is implemented by the {@link SSubCommand} class, which defines its specific execution logic.

@@ -300,7 +247,7 @@ public class VMOpCode { *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, * primarily used to handle basic short16 subtraction tasks.

*/ - public static final int S_SUB = 21; + public static final int S_SUB = 0x0021; /** * S_MUL Opcode: Represents the short16 multiplication operation in the virtual machine. *

This opcode is implemented by the {@link SMulCommand} class, which defines its specific execution logic.

@@ -315,7 +262,7 @@ public class VMOpCode { *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, * primarily used to handle basic short16 multiplication tasks.

*/ - public static final int S_MUL = 22; + public static final int S_MUL = 0x0022; /** * S_DIV Opcode: Represents the short16 division operation in the virtual machine. *

This opcode is implemented by the {@link SDivCommand} class, which defines its specific execution logic.

@@ -331,7 +278,7 @@ public class VMOpCode { *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, * primarily used to handle basic short16 division tasks.

*/ - public static final int S_DIV = 23; + public static final int S_DIV = 0x0023; /** * S_MOD Opcode: Represents the short16 modulus (remainder) operation in the virtual machine. *

This opcode is implemented by the {@link SModCommand} class, which defines its specific execution logic.

@@ -347,7 +294,21 @@ public class VMOpCode { *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, * primarily used to handle basic short16 modulus (remainder) tasks.

*/ - public static final int S_MOD = 24; + public static final int S_MOD = 0x0024; + /** + * S_NEG Opcode: Represents the short16 negation operation in the virtual machine. + *

This opcode is implemented by the {@link SNegCommand} class, which defines its specific execution logic.

+ * + *

Execution Steps:

+ *
    + *
  1. Pops the top short16 value from the operand stack.
  2. + *
  3. Performs the negation of the popped value (i.e., -value).
  4. + *
  5. Pushes the negated result back onto the operand stack for later instructions to use.
  6. + *
+ * + *

This opcode is typically used to negate a short16 value, making it a fundamental operation for arithmetic logic within the virtual machine.

+ */ + public static final int S_NEG = 0x0025; /** * S_INC Opcode: Represents the short16 increment operation in the virtual machine. *

This opcode is implemented by the {@link SIncCommand} class, which defines its specific execution logic.

@@ -365,1040 +326,12 @@ public class VMOpCode { *

This opcode is useful for scenarios where a local variable needs to be incremented, such as counters within loops, * or for optimizing the modification of variables in tight loops.

*/ - public static final int S_INC = 25; - /** - * S_NEG Opcode: Represents the short16 negation operation in the virtual machine. - *

This opcode is implemented by the {@link SNegCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top short16 value from the operand stack.
  2. - *
  3. Performs the negation of the popped value (i.e., -value).
  4. - *
  5. Pushes the negated result back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is typically used to negate a short16 value, making it a fundamental operation for arithmetic logic within the virtual machine.

- */ - public static final int S_NEG = 26; - // endregion + public static final int S_INC = 0x0026; - // region 1.4 byte8 (31-40) - /** - * B_ADD Opcode: Represents the byte8 addition operation in the virtual machine. - *

This opcode is implemented by the {@link BAddCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two byte8 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the addition operation on these two byte8 values.
  4. - *
  5. Pushes the result of the addition back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic byte8 addition tasks.

- */ - public static final int B_ADD = 31; - /** - * B_SUB Opcode: Represents the byte8 subtraction operation in the virtual machine. - *

This opcode is implemented by the {@link BSubCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two byte8 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
  2. - *
  3. Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
  4. - *
  5. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic byte8 subtraction tasks.

- */ - public static final int B_SUB = 32; - /** - * B_MUL Opcode: Represents the byte8 multiplication operation in the virtual machine. - *

This opcode is implemented by the {@link BMulCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two byte8 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the multiplication operation on these two byte8 values (i.e., firstOperand * secondOperand).
  4. - *
  5. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic byte8 multiplication tasks.

- */ - public static final int B_MUL = 33; - /** - * B_DIV Opcode: Represents the byte8 division operation in the virtual machine. - *

This opcode is implemented by the {@link BDivCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two byte8 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. - *
  3. Performs the division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
  4. - *
  5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  6. - *
  7. Pushes the result of the division back onto the operand stack for later instructions to use.
  8. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic byte8 division tasks.

- */ - public static final int B_DIV = 34; - /** - * B_MOD Opcode: Represents the byte8 modulus (remainder) operation in the virtual machine. - *

This opcode is implemented by the {@link BModCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two byte8 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. - *
  3. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
  4. - *
  5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  6. - *
  7. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
  8. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic byte8 modulus (remainder) tasks.

- */ - public static final int B_MOD = 35; - /** - * B_INC Opcode: Represents the byte8 increment operation for a local variable in the virtual machine. - *

This opcode is implemented by the {@link BIncCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Retrieves the index of the local variable and the increment value from the instruction parameters.
  2. - *
  3. Gets the current value of the local variable at the specified index from the local variable store.
  4. - *
  5. Increments the local variable's value by the specified increment (i.e., - * localVariables[index] += increment).
  6. - *
  7. Updates the local variable store with the new incremented value.
  8. - *
  9. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
  10. - *
- * - *

This opcode is particularly useful for optimizing scenarios where a local `byte8` variable, such as a counter or loop index, is frequently incremented.

- */ - public static final int B_INC = 36; - /** - * B_NEG Opcode: Represents the byte8 negation operation in the virtual machine. - *

This opcode is implemented by the {@link BNegCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top byte8 value from the operand stack.
  2. - *
  3. Performs the negation of the popped value (i.e., -value).
  4. - *
  5. Pushes the negated result back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is typically used to negate a byte8 value, making it a fundamental operation for arithmetic logic within the virtual machine.

- */ - public static final int B_NEG = 37; - // endregion + public static final int S_AND = 0x0027; + public static final int S_OR = 0x0028; + public static final int S_XOR = 0x0029; - // region 1.5 double64 (41-50) - /** - * D_ADD Opcode: Represents the double64 precision floating-point addition operation in the virtual machine. - *

This opcode is implemented by the {@link DAddCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two double64 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the double64 precision floating-point addition operation on these two operands.
  4. - *
  5. Pushes the result of the addition back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic double64 precision floating-point addition tasks.

- */ - public static final int D_ADD = 41; - /** - * D_SUB Opcode: Represents the double64 precision floating-point subtraction operation in the virtual machine. - *

This opcode is implemented by the {@link DSubCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two double64 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
  2. - *
  3. Performs the double64 precision floating-point subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
  4. - *
  5. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic double64 precision floating-point subtraction tasks.

- */ - public static final int D_SUB = 42; - /** - * D_MUL Opcode: Represents the double64 precision floating-point multiplication operation in the virtual machine. - *

This opcode is implemented by the {@link DMulCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two double64 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the double64 precision floating-point multiplication operation on these two operands (i.e., firstOperand * secondOperand).
  4. - *
  5. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic double64 precision floating-point multiplication tasks.

- */ - public static final int D_MUL = 43; - /** - * D_DIV Opcode: Represents the double64 precision floating-point division operation in the virtual machine. - *

This opcode is implemented by the {@link DDivCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two double64 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. - *
  3. Performs the double64 precision floating-point division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
  4. - *
  5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  6. - *
  7. Pushes the result of the division back onto the operand stack for later instructions to use.
  8. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic double64 precision floating-point division tasks.

- */ - public static final int D_DIV = 44; - /** - * D_MOD Opcode: Represents the double64 precision floating-point modulus (remainder) operation in the virtual machine. - *

This opcode is implemented by the {@link DModCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two double64 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. - *
  3. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
  4. - *
  5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  6. - *
  7. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
  8. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic double64 precision floating-point modulus (remainder) tasks.

- */ - public static final int D_MOD = 45; - /** - * D_INC Opcode: Represents the double64 increment operation for a local variable in the virtual machine. - *

This opcode is implemented by the {@link DIncCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Retrieves the index of the local variable and the increment value from the instruction parameters.
  2. - *
  3. Gets the current value of the local variable at the specified index from the local variable store.
  4. - *
  5. Increments the local variable's value by the specified increment (i.e., - * localVariables[index] += increment).
  6. - *
  7. Updates the local variable store with the new incremented value.
  8. - *
  9. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
  10. - *
- * - *

This opcode is particularly useful for optimizing scenarios where a local `double64` variable, such as a counter or loop index, is frequently incremented.

- */ - public static final int D_INC = 46; - /** - * D_NEG Opcode: Represents the double64 precision floating-point negation operation in the virtual machine. - *

This opcode is implemented by the {@link DNegCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top double64 value from the operand stack.
  2. - *
  3. Performs the negation of the popped value (i.e., -value).
  4. - *
  5. Pushes the negated result back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is typically used to negate a double64 precision floating-point value, making it a fundamental operation for double64 precision arithmetic logic within the virtual machine.

- */ - public static final int D_NEG = 47; - // endregion - - // region 1.6 float32 (51-60) - /** - * F_ADD Opcode: Represents the float32 addition operation in the virtual machine. - *

This opcode is implemented by the {@link FAddCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two float32 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the float32 addition operation on these two operands.
  4. - *
  5. Pushes the result of the addition back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic float32 addition tasks.

- */ - public static final int F_ADD = 51; - /** - * F_SUB Opcode: Represents the float32 subtraction operation in the virtual machine. - *

This opcode is implemented by the {@link FSubCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two float32 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
  2. - *
  3. Performs the float32 subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
  4. - *
  5. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic float32 subtraction tasks.

- */ - public static final int F_SUB = 52; - /** - * F_MUL Opcode: Represents the float32 multiplication operation in the virtual machine. - *

This opcode is implemented by the {@link FMulCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two float32 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
  2. - *
  3. Performs the float32 multiplication operation on these two operands (i.e., firstOperand * secondOperand).
  4. - *
  5. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic float32 multiplication tasks.

- */ - public static final int F_MUL = 53; - /** - * F_DIV Opcode: Represents the float32 division operation in the virtual machine. - *

This opcode is implemented by the {@link FDivCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two float32 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. - *
  3. Performs the float32 division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
  4. - *
  5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  6. - *
  7. Pushes the result of the division back onto the operand stack for later instructions to use.
  8. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic float32 division tasks.

- */ - public static final int F_DIV = 54; - /** - * F_MOD Opcode: Represents the float32 modulus (remainder) operation in the virtual machine. - *

This opcode is implemented by the {@link FModCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two float32 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
  2. - *
  3. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
  4. - *
  5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
  6. - *
  7. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
  8. - *
- * - *

This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, - * primarily used to handle basic float32 modulus (remainder) tasks.

- */ - public static final int F_MOD = 55; - /** - * F_INC Opcode: Represents the float32 increment operation for a local variable in the virtual machine. - *

This opcode is implemented by the {@link FIncCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Retrieves the index of the local variable and the increment value from the instruction parameters.
  2. - *
  3. Gets the current value of the local variable at the specified index from the local variable store.
  4. - *
  5. Increments the local variable's value by the specified increment (i.e., - * localVariables[index] += increment).
  6. - *
  7. Updates the local variable store with the new incremented value.
  8. - *
  9. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
  10. - *
- * - *

This opcode is particularly useful for optimizing scenarios where a local `float32` variable, such as a counter or loop index, is frequently incremented.

- */ - public static final int F_INC = 56; - /** - * F_NEG Opcode: Represents the float32 negation operation in the virtual machine. - *

This opcode is implemented by the {@link FNegCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top float32 value from the operand stack.
  2. - *
  3. Performs the negation of the popped value (i.e., -value).
  4. - *
  5. Pushes the negated result back onto the operand stack for later instructions to use.
  6. - *
- * - *

This opcode is typically used to negate a float32 value, making it a fundamental operation for float32 arithmetic logic within the virtual machine.

- */ - public static final int F_NEG = 57; - // endregion - // endregion - - // region 2. Type Conversion Operation - /** - * I2L Opcode: Represents the type conversion operation from int32 to long64 in the virtual machine. - *

This opcode is implemented by the {@link I2LCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top int32 value from the operand stack.
  2. - *
  3. Convert the int32 value to a long64 value.
  4. - *
  5. Push the converted long64 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is commonly used to widen an int32 value to a long64 type to accommodate larger numeric ranges.

- */ - public static final int I2L = 61; - /** - * I2S Opcode: Represents the type conversion operation from int32 to short16 in the virtual machine. - *

This opcode is implemented by the {@link I2SCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top int32 value from the operand stack.
  2. - *
  3. Convert the int32 value to a short16 value (this may involve truncation).
  4. - *
  5. Push the converted short16 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is typically used to narrow an int32 value to a short16 type when a smaller data representation is needed.

- */ - public static final int I2S = 62; - /** - * I2B Opcode: Represents the type conversion operation from int32 to byte8 in the virtual machine. - *

This opcode is implemented by the {@link I2BCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top int32 value from the operand stack.
  2. - *
  3. Convert the int32 value to a byte8 value (this may involve truncation).
  4. - *
  5. Push the converted byte8 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to narrow an int32 value to a byte8 type, suitable when a smaller numeric type is required.

- */ - public static final int I2B = 63; - /** - * I2D Opcode: Represents the type conversion operation from int32 to double64 in the virtual machine. - *

This opcode is implemented by the {@link I2DCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top int32 value from the operand stack.
  2. - *
  3. Convert the int32 value to a double64 value.
  4. - *
  5. Push the converted double64 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to widen an int32 value to a double64 type, providing high-precision floating-point calculations.

- */ - public static final int I2D = 64; - /** - * I2F Opcode: Represents the type conversion operation from int32 to float32 in the virtual machine. - *

This opcode is implemented by the {@link I2FCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top int32 value from the operand stack.
  2. - *
  3. Convert the int32 value to a float32 value.
  4. - *
  5. Push the converted float32 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to convert an int32 value to a float32 type when floating-point arithmetic is required.

- */ - public static final int I2F = 65; - /** - * L2I Opcode: Represents the type conversion operation from long64 to int32 in the virtual machine. - *

This opcode is implemented by the {@link L2ICommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top long64 value from the operand stack.
  2. - *
  3. Convert the long64 value to an int32 value (this may involve truncation).
  4. - *
  5. Push the converted int32 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is typically used to narrow a long64 value to an int32 type for further integer operations.

- */ - public static final int L2I = 66; - /** - * L2D Opcode: Represents the type conversion operation from long64 to double64 in the virtual machine. - *

This opcode is implemented by the {@link L2DCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top long64 value from the operand stack.
  2. - *
  3. Convert the long64 value to a double64 value.
  4. - *
  5. Push the converted double64 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to widen a long64 value to a double64 type for high-precision floating-point computations.

- */ - public static final int L2D = 67; - - /** - * L2F Opcode: Represents the type conversion operation from long64 to float32 in the virtual machine. - *

This opcode is implemented by the {@link L2FCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top long64 value from the operand stack.
  2. - *
  3. Convert the long64 value to a float32 value.
  4. - *
  5. Push the converted float32 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to convert a long64 value to a float32 type, typically for floating-point arithmetic involving long values.

- */ - public static final int L2F = 68; - - /** - * F2I Opcode: Represents the type conversion operation from float32 to int32 in the virtual machine. - *

This opcode is implemented by the {@link F2ICommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top float32 value from the operand stack.
  2. - *
  3. Convert the float32 value to an int32 value (this may involve truncation).
  4. - *
  5. Push the converted int32 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to convert a float32 value to an int32 type for further integer-based operations or comparisons.

- */ - public static final int F2I = 69; - - /** - * F2L Opcode: Represents the type conversion operation from float32 to long64 in the virtual machine. - *

This opcode is implemented by the {@link F2LCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top float32 value from the operand stack.
  2. - *
  3. Convert the float32 value to a long64 value.
  4. - *
  5. Push the converted long64 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to widen a float32 value to a long64 type, which is useful when operations require a larger numeric range.

- */ - public static final int F2L = 70; - - /** - * F2D Opcode: Represents the type conversion operation from float32 to double64 in the virtual machine. - *

This opcode is implemented by the {@link F2DCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top float32 value from the operand stack.
  2. - *
  3. Convert the float32 value to a double64 value.
  4. - *
  5. Push the converted double64 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to promote a float32 value to a double64 type, thereby increasing precision for floating-point computations.

- */ - public static final int F2D = 71; - - /** - * D2I Opcode: Represents the type conversion operation from double64 to int32 in the virtual machine. - *

This opcode is implemented by the {@link D2ICommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top double64 value from the operand stack.
  2. - *
  3. Convert the double64 value to an int32 value (this may involve truncation).
  4. - *
  5. Push the converted int32 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to narrow a double64 value to an int32 type for further integer-based processing.

- */ - public static final int D2I = 72; - - /** - * D2L Opcode: Represents the type conversion operation from double64 to long64 in the virtual machine. - *

This opcode is implemented by the {@link D2LCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top double64 value from the operand stack.
  2. - *
  3. Convert the double64 value to a long64 value (this may involve truncation).
  4. - *
  5. Push the converted long64 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to narrow a double64 value to a long64 type, which can then be used for integer operations.

- */ - public static final int D2L = 73; - - /** - * D2F Opcode: Represents the type conversion operation from double64 to float32 in the virtual machine. - *

This opcode is implemented by the {@link D2FCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top double64 value from the operand stack.
  2. - *
  3. Convert the double64 value to a float32 value.
  4. - *
  5. Push the converted float32 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to narrow a double64 value to a float32 type when lower precision floating-point arithmetic is acceptable.

- */ - public static final int D2F = 74; - - /** - * S2I Opcode: Represents the type conversion operation from short16 to int32 in the virtual machine. - *

This opcode is implemented by the {@link S2ICommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top short16 value from the operand stack.
  2. - *
  3. Convert the short16 value to an int32 value.
  4. - *
  5. Push the converted int32 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to widen a short16 value to an int32 type, facilitating subsequent integer arithmetic or comparison operations.

- */ - public static final int S2I = 75; - - /** - * B2I Opcode: Represents the type conversion operation from byte8 to int32 in the virtual machine. - *

This opcode is implemented by the {@link B2ICommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pop the top byte8 value from the operand stack.
  2. - *
  3. Convert the byte8 value to an int32 value.
  4. - *
  5. Push the converted int32 value back onto the operand stack for subsequent operations.
  6. - *
- * - *

This opcode is used to widen a byte8 value to an int32 type to ensure compatibility with integer-based operations.

- */ - public static final int B2I = 76; - // endregion - - // region 2. Bitwise Operations (81–90) - // region 2.1 int32 (81-85) - /** - * I_AND Opcode: Represents the int32 bitwise AND operation in the virtual machine. - *

This opcode is implemented by the {@link IAndCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
  2. - *
  3. Performs the int32 bitwise AND operation on the two popped operands. The operation compares corresponding bits of both operands: - * - *
  4. - *
  5. Pushes the result of the int32 bitwise AND operation back onto the operand stack for further processing.
  6. - *
- * - *

This opcode is essential for low-level bit manipulation tasks.

- */ - public static final int I_AND = 81; - /** - * I_OR Opcode: Represents the int32 bitwise OR operation in the virtual machine. - *

This opcode is implemented by the {@link IOrCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
  2. - *
  3. Performs the int32 bitwise OR operation on the two popped operands. The operation compares corresponding bits of both operands: - * - *
  4. - *
  5. Pushes the result of the int32 bitwise OR operation back onto the operand stack for further processing.
  6. - *
- * - *

This opcode is essential for low-level bit manipulation tasks.

- */ - public static final int I_OR = 82; - - /** - * I_XOR Opcode: Represents the int32 bitwise XOR operation in the virtual machine. - *

This opcode is implemented by the {@link IXorCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
  2. - *
  3. Performs the int32 bitwise XOR (exclusive OR) operation on the two operands: - * - *
  4. - *
  5. Pushes the result of the int32 bitwise XOR operation back onto the operand stack for further processing.
  6. - *
- * - *

This opcode is essential for low-level bit manipulation tasks.

- */ - public static final int I_XOR = 83; - - // endregion - // region 2.2 Long64 (86-90) - /** - * L_AND Opcode: Represents the long64 bitwise AND operation in the virtual machine. - *

This opcode is implemented by the {@link LAndCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two long64 values from the operand stack. These values are treated as 32-bit binary representations.
  2. - *
  3. Performs the long64 bitwise AND operation on the two popped operands. The operation compares corresponding bits of both operands: - * - *
  4. - *
  5. Pushes the result of the long64 bitwise AND operation back onto the operand stack for further processing.
  6. - *
- * - *

This opcode is essential for low-level bit manipulation tasks.

- */ - public static final int L_AND = 86; - /** - * L_OR Opcode: Represents the long64 bitwise OR operation in the virtual machine. - *

This opcode is implemented by the {@link LOrCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two long64 values from the operand stack. These values are treated as 32-bit binary representations.
  2. - *
  3. Performs the long64 bitwise OR operation on the two popped operands. The operation compares corresponding bits of both operands: - * - *
  4. - *
  5. Pushes the result of the long64 bitwise OR operation back onto the operand stack for further processing.
  6. - *
- * - *

This opcode is essential for low-level bit manipulation tasks.

- */ - public static final int L_OR = 87; - - /** - * L_XOR Opcode: Represents the long64 bitwise XOR operation in the virtual machine. - *

This opcode is implemented by the {@link LXorCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Pops the top two long64 values from the operand stack. These values are treated as 32-bit binary representations.
  2. - *
  3. Performs the long64 bitwise XOR (exclusive OR) operation on the two operands: - * - *
  4. - *
  5. Pushes the result of the long64 bitwise XOR operation back onto the operand stack for further processing.
  6. - *
- * - *

This opcode is essential for low-level bit manipulation tasks.

- */ - public static final int L_XOR = 88; - - - // endregion - // endregion - // region 3. Control Flow Operations (91–110) - // region 3.1 JUMP (91-91) - /** - * JUMP Opcode: Represents an unconditional jump to a target instruction address. - *

This opcode is implemented by the {@link JumpCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Validates the target address to ensure it is a non-negative int32.
  4. - *
  5. If the target address is valid (greater than or equal to 0), updates the program counter (PC) to the specified target address, - * effectively skipping all intermediate instructions.
  6. - *
  7. If the target address is invalid (less than 0), logs an error message and halts execution by returning an invalid value (typically -1).
  8. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int JUMP = 91; - - // endregion - // region 3.2 int32 (92-97) - /** - * IC_E Opcode: Represents a conditional jump based on int32 equality. - *

This opcode is implemented by the {@link ICECommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two int32 values from the operand stack.
  4. - *
  5. Compares the two int32s for equality.
  6. - *
  7. If the int32s are equal, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the int32s are not equal, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int IC_E = 92; - /** - * IC_NE Opcode: Represents a conditional jump based on int32 inequality. - *

This opcode is implemented by the {@link ICNECommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two int32 values from the operand stack.
  4. - *
  5. Compares the two int32s for inequality.
  6. - *
  7. If the int32s are not equal, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the int32s are equal, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int IC_NE = 93; - /** - * IC_G Opcode: Represents a conditional jump based on int32 comparison (greater than). - *

This opcode is implemented by the {@link ICGCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two int32 values from the operand stack.
  4. - *
  5. Compares the first int32 with the second to determine if it is greater.
  6. - *
  7. If the first int32 is greater than the second, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the first int32 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int IC_G = 94; - /** - * IC_GE Opcode: Represents a conditional jump based on int32 comparison (greater than or equal to). - *

This opcode is implemented by the {@link ICGECommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two int32 values from the operand stack.
  4. - *
  5. Compares the first int32 with the second to determine if it is greater than or equal to the second int32.
  6. - *
  7. If the first int32 is greater than or equal to the second, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the first int32 is less than the second, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int IC_GE = 95; - /** - * IC_L Opcode: Represents a conditional jump based on int32 comparison (less than). - *

This opcode is implemented by the {@link ICLCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two int32 values from the operand stack.
  4. - *
  5. Compares the first int32 with the second to determine if it is less than the second int32.
  6. - *
  7. If the first int32 is less than the second, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the first int32 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int IC_L = 96; - /** - * IC_LE Opcode: Represents a conditional jump based on int32 comparison (less than or equal). - *

This opcode is implemented by the {@link ICLECommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two int32 values from the operand stack.
  4. - *
  5. Compares the first int32 with the second to determine if it is less than or equal to the second int32.
  6. - *
  7. If the first int32 is less than or equal to the second, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the first int32 is greater than the second, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int IC_LE = 97; - - // endregion - // region 3.3 long64 (98-103) - /** - * LC_E Opcode: Represents a conditional jump based on long64 equality. - *

This opcode is implemented by the {@link ICECommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two long64 values from the operand stack.
  4. - *
  5. Compares the two long64s for equality.
  6. - *
  7. If the long64s are equal, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the long64s are not equal, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int LC_E = 98; - /** - * LC_NE Opcode: Represents a conditional jump based on long64 inequality. - *

This opcode is implemented by the {@link ICNECommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two long64 values from the operand stack.
  4. - *
  5. Compares the two long64s for inequality.
  6. - *
  7. If the long64s are not equal, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the long64s are equal, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int LC_NE = 99; - /** - * LC_G Opcode: Represents a conditional jump based on long64 comparison (greater than). - *

This opcode is implemented by the {@link ICGCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two long64 values from the operand stack.
  4. - *
  5. Compares the first long64 with the second to determine if it is greater.
  6. - *
  7. If the first long64 is greater than the second, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the first long64 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int LC_G = 100; - /** - * LC_GE Opcode: Represents a conditional jump based on long64 comparison (greater than or equal to). - *

This opcode is implemented by the {@link ICGECommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two long64 values from the operand stack.
  4. - *
  5. Compares the first long64 with the second to determine if it is greater than or equal to the second long64.
  6. - *
  7. If the first long64 is greater than or equal to the second, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the first long64 is less than the second, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int LC_GE = 101; - /** - * LC_L Opcode: Represents a conditional jump based on long64 comparison (less than). - *

This opcode is implemented by the {@link ICLCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two long64 values from the operand stack.
  4. - *
  5. Compares the first long64 with the second to determine if it is less than the second long64.
  6. - *
  7. If the first long64 is less than the second, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the first long64 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int LC_L = 102; - /** - * LC_LE Opcode: Represents a conditional jump based on long64 comparison (less than or equal). - *

This opcode is implemented by the {@link ICLECommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the target instruction address from the instruction parameters.
  2. - *
  3. Pops two long64 values from the operand stack.
  4. - *
  5. Compares the first long64 with the second to determine if it is less than or equal to the second long64.
  6. - *
  7. If the first long64 is less than or equal to the second, updates the program counter (PC) to the specified target address, - * effectively jumping to the target instruction.
  8. - *
  9. If the first long64 is greater than the second, increments the program counter to proceed with the next sequential instruction.
  10. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int LC_LE = 103; - - // endregion - // endregion - // region 4. Stack Operations (111–150) - // region 4.1 PUSH (111-120) - /** - * I_PUSH Opcode: Represents a stack operation that pushes an int32 value onto the operand stack. - *

This opcode is implemented by the {@link IPushCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the int32 value from the instruction parameters.
  2. - *
  3. Pushes the parsed int32 value onto the operand stack.
  4. - *
  5. Increments the program counter (PC) to proceed with the next sequential instruction.
  6. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int I_PUSH = 111; - /** - * L_PUSH Opcode: Represents a stack operation that pushes a long64 value onto the operand stack. - *

This opcode is implemented by the {@link LPushCommand} class, which defines its specific execution logic.

- * - *

Execution Steps:

- *
    - *
  1. Parses the long64 value from the instruction parameters.
  2. - *
  3. Pushes the parsed long64 value onto the operand stack.
  4. - *
  5. Increments the program counter (PC) to proceed with the next sequential instruction.
  6. - *
- * - *

This opcode is commonly used for:

- * - */ - public static final int L_PUSH = 112; /** * S_PUSH Opcode: Represents a stack operation that pushes a short16 value onto the operand stack. *

This opcode is implemented by the {@link SPushCommand} class, which defines its specific execution logic.

@@ -1417,15 +350,231 @@ public class VMOpCode { *
  • Facilitating method calls or control flow by managing stack-based data.
  • * */ - public static final int S_PUSH = 113; + public static final int S_PUSH = 0x002A; /** - * I_PUSH Opcode: Represents a stack operation that pushes a byte8 value onto the operand stack. - *

    This opcode is implemented by the {@link BPushCommand} class, which defines its specific execution logic.

    + * S_LOAD Opcode: Represents a load operation that retrieves a short16 value from the local variable store and pushes it onto the operand stack. + *

    This opcode is implemented by the {@link SLoadCommand} class, which defines its specific execution logic.

    * *

    Execution Steps:

    *
      - *
    1. Parses the byte8 value from the instruction parameters.
    2. - *
    3. Pushes the parsed byte8 value onto the operand stack.
    4. + *
    5. Retrieves the index for the local variable from the instruction parameters.
    6. + *
    7. Retrieves the corresponding value from the local variable store of the current method frame.
    8. + *
    9. Pushes the retrieved value onto the operand stack for subsequent operations.
    10. + *
    11. Increments the program counter (PC) to proceed with the next sequential instruction.
    12. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int S_LOAD = 0x002B; + /** + * S_STORE Opcode: Represents a store operation that stores a short16 value from the operand stack into the local variable store. + *

    This opcode is implemented by the {@link SStoreCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. + *
    3. Pops a short16 value from the operand stack.
    4. + *
    5. Stores the value into the local variable store at the specified index of the current method frame.
    6. + *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int S_STORE = 0x002C; + + public static final int S_CE = 0x002D; + public static final int S_CNE = 0x002E; + public static final int S_CG = 0x002F; + public static final int S_CGE = 0x0030; + public static final int S_CL = 0x0031; + public static final int S_CLE = 0x0032; + + // endregion + + // region Int32 (0x0040-0x005F) + /** + * I_ADD Opcode: Represents the int32 addition operation in the virtual machine. + *

    This opcode is implemented by the {@link IAddCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two int32 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
    2. + *
    3. Performs the addition operation on these two int32s.
    4. + *
    5. Pushes the result of the addition back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic int32 addition tasks.

    + */ + public static final int I_ADD = 0x0040; + /** + * I_SUB Opcode: Represents the int32 subtraction operation in the virtual machine. + *

    This opcode is implemented by the {@link ISubCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two int32 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
    2. + *
    3. Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
    4. + *
    5. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic int32 subtraction tasks.

    + */ + public static final int I_SUB = 0x0041; + /** + * I_MUL Opcode: Represents the int32 multiplication operation in the virtual machine. + *

    This opcode is implemented by the {@link IMulCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two int32 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
    2. + *
    3. Performs the multiplication operation on these two int32s (i.e., firstOperand * secondOperand).
    4. + *
    5. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic int32 multiplication tasks.

    + */ + public static final int I_MUL = 0x0042; + /** + * I_DIV Opcode: Represents the int32 division operation in the virtual machine. + *

    This opcode is implemented by the {@link IDivCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two int32 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
    2. + *
    3. Performs the division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
    4. + *
    5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
    6. + *
    7. Pushes the result of the division back onto the operand stack for later instructions to use.
    8. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic int32 division tasks.

    + */ + public static final int I_DIV = 0x0043; + /** + * I_MOD Opcode: Represents the int32 modulus (remainder) operation in the virtual machine. + *

    This opcode is implemented by the {@link IModCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two int32 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
    2. + *
    3. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
    4. + *
    5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
    6. + *
    7. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
    8. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic int32 modulus (remainder) tasks.

    + */ + public static final int I_MOD = 0x0044; + /** + * I_NEG Opcode: Represents the int32 negation operation in the virtual machine. + *

    This opcode is implemented by the {@link INegCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top int32 value from the operand stack.
    2. + *
    3. Performs the negation of the popped value (i.e., -value).
    4. + *
    5. Pushes the negated result back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is typically used to negate an int32 value, making it a fundamental operation for arithmetic logic within the virtual machine.

    + */ + public static final int I_NEG = 0x0045; + /** + * I_INC Opcode: Represents the int32 increment operation for a local variable in the virtual machine. + *

    This opcode is implemented by the {@link IIncCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Retrieves the index of the local variable and the increment value from the instruction parameters.
    2. + *
    3. Gets the current value of the local variable at the specified index from the local variable store.
    4. + *
    5. Increments the local variable's value by the specified increment (i.e., + * localVariables[index] += increment).
    6. + *
    7. Updates the local variable store with the new incremented value.
    8. + *
    9. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
    10. + *
    + * + *

    This opcode is particularly useful for optimizing scenarios where a local variable, such as a counter or loop index, is frequently incremented.

    + */ + public static final int I_INC = 0x0046; + /** + * I_AND Opcode: Represents the int32 bitwise AND operation in the virtual machine. + *

    This opcode is implemented by the {@link IAndCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
    2. + *
    3. Performs the int32 bitwise AND operation on the two popped operands. The operation compares corresponding bits of both operands: + * + *
    4. + *
    5. Pushes the result of the int32 bitwise AND operation back onto the operand stack for further processing.
    6. + *
    + * + *

    This opcode is essential for low-level bit manipulation tasks.

    + */ + public static final int I_AND = 0x0047; + /** + * I_OR Opcode: Represents the int32 bitwise OR operation in the virtual machine. + *

    This opcode is implemented by the {@link IOrCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
    2. + *
    3. Performs the int32 bitwise OR operation on the two popped operands. The operation compares corresponding bits of both operands: + * + *
    4. + *
    5. Pushes the result of the int32 bitwise OR operation back onto the operand stack for further processing.
    6. + *
    + * + *

    This opcode is essential for low-level bit manipulation tasks.

    + */ + public static final int I_OR = 0x0048; + /** + * I_XOR Opcode: Represents the int32 bitwise XOR operation in the virtual machine. + *

    This opcode is implemented by the {@link IXorCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
    2. + *
    3. Performs the int32 bitwise XOR (exclusive OR) operation on the two operands: + * + *
    4. + *
    5. Pushes the result of the int32 bitwise XOR operation back onto the operand stack for further processing.
    6. + *
    + * + *

    This opcode is essential for low-level bit manipulation tasks.

    + */ + public static final int I_XOR = 0x0049; + /** + * I_PUSH Opcode: Represents a stack operation that pushes an int32 value onto the operand stack. + *

    This opcode is implemented by the {@link IPushCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the int32 value from the instruction parameters.
    2. + *
    3. Pushes the parsed int32 value onto the operand stack.
    4. *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. *
    * @@ -1436,115 +585,27 @@ public class VMOpCode { *
  • Facilitating method calls or control flow by managing stack-based data.
  • * */ - public static final int B_PUSH = 114; + public static final int I_PUSH = 0x004A; /** - * I_PUSH Opcode: Represents a stack operation that pushes a double64 value onto the operand stack. - *

    This opcode is implemented by the {@link DPushCommand} class, which defines its specific execution logic.

    + * I_LOAD Opcode: Represents a load operation that retrieves an int32 value from the local variable store and pushes it onto the operand stack. + *

    This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.

    * *

    Execution Steps:

    *
      - *
    1. Parses the double64 value from the instruction parameters.
    2. - *
    3. Pushes the parsed double64 value onto the operand stack.
    4. + *
    5. Retrieves the index for the local variable from the instruction parameters.
    6. + *
    7. Retrieves the corresponding value from the local variable store of the current method frame.
    8. + *
    9. Pushes the retrieved value onto the operand stack for subsequent operations.
    10. *
    11. Increments the program counter (PC) to proceed with the next sequential instruction.
    12. *
    * *

    This opcode is commonly used for:

    * */ - public static final int D_PUSH = 115; - /** - * F_PUSH Opcode: Represents a stack operation that pushes a float32 value onto the operand stack. - *

    This opcode is implemented by the {@link FPushCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Parses the float32 value from the instruction parameters.
    2. - *
    3. Pushes the parsed float32 value onto the operand stack.
    4. - *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int F_PUSH = 116; - // endregion - // region 4.2 POP (121-125) - /** - * I_POP Opcode: Represents a stack operation that removes the top element from the operand stack. - *

    This opcode is implemented by the {@link PopCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Removes (pops) the top element from the operand stack.
    2. - *
    3. Discards the popped value, as it is not stored or used further.
    4. - *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int POP = 121; - // endregion - // region 4.3 DUP (126-130) - /** - * DUP Opcode: Represents a stack operation that duplicates the top element of the operand stack. - *

    This opcode is implemented by the {@link DupCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Retrieves the top element from the operand stack.
    2. - *
    3. Duplicates the top value and pushes it back onto the stack.
    4. - *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - - public static final int DUP = 126; - // endregion - - // region 4.4 SWAP (131-135) - /** - * SWAP Opcode: Represents a stack operation that swaps the top two values of the operand stack. - *

    This opcode is implemented by the {@link SwapCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Ensures that there are at least two elements on the operand stack.
    2. - *
    3. Pops the two topmost values from the stack.
    4. - *
    5. Pushes the two values back onto the stack in reversed order.
    6. - *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int SWAP = 131; - // endregion - - // endregion - // region 5. Memory Operations (151–166) + public static final int I_LOAD = 0x004B; /** * I_STORE Opcode: Represents a store operation that saves an int32 value from the operand stack into the local variable store. * @@ -1565,127 +626,320 @@ public class VMOpCode { *
  • Transferring values from the operand stack to the method-local scope.
  • * */ - public static final int I_STORE = 151; + public static final int I_STORE = 0x004C; /** - * L_STORE Opcode: Represents a store operation that stores a long64 value from the operand stack into the local variable store. - *

    This opcode is implemented by the {@link LStoreCommand} class, which defines its specific execution logic.

    + * I_CE Opcode: Represents a conditional jump based on int32 equality. + *

    This opcode is implemented by the {@link ICECommand} class, which defines its specific execution logic.

    * *

    Execution Steps:

    *
      - *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Pops a long64 value from the operand stack.
    4. - *
    5. Stores the value into the local variable store at the specified index of the current method frame.
    6. + *
    7. Parses the target instruction address from the instruction parameters.
    8. + *
    9. Pops two int32 values from the operand stack.
    10. + *
    11. Compares the two int32s for equality.
    12. + *
    13. If the int32s are equal, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    14. + *
    15. If the int32s are not equal, increments the program counter to proceed with the next sequential instruction.
    16. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int I_CE = 0x004D; + /** + * I_CNE Opcode: Represents a conditional jump based on int32 inequality. + *

    This opcode is implemented by the {@link ICNECommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two int32 values from the operand stack.
    4. + *
    5. Compares the two int32s for inequality.
    6. + *
    7. If the int32s are not equal, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the int32s are equal, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int I_CNE = 0x004E; + /** + * I_CG Opcode: Represents a conditional jump based on int32 comparison (greater than). + *

    This opcode is implemented by the {@link ICGCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two int32 values from the operand stack.
    4. + *
    5. Compares the first int32 with the second to determine if it is greater.
    6. + *
    7. If the first int32 is greater than the second, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the first int32 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int I_CG = 0x004F; + /** + * I_CGE Opcode: Represents a conditional jump based on int32 comparison (greater than or equal to). + *

    This opcode is implemented by the {@link ICGECommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two int32 values from the operand stack.
    4. + *
    5. Compares the first int32 with the second to determine if it is greater than or equal to the second int32.
    6. + *
    7. If the first int32 is greater than or equal to the second, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the first int32 is less than the second, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int I_CGE = 0x0050; + /** + * I_CL Opcode: Represents a conditional jump based on int32 comparison (less than). + *

    This opcode is implemented by the {@link ICLCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two int32 values from the operand stack.
    4. + *
    5. Compares the first int32 with the second to determine if it is less than the second int32.
    6. + *
    7. If the first int32 is less than the second, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the first int32 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int I_CL = 0x0051; + /** + * I_CLE Opcode: Represents a conditional jump based on int32 comparison (less than or equal). + *

    This opcode is implemented by the {@link ICLECommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two int32 values from the operand stack.
    4. + *
    5. Compares the first int32 with the second to determine if it is less than or equal to the second int32.
    6. + *
    7. If the first int32 is less than or equal to the second, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the first int32 is greater than the second, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int I_CLE = 0x0052; + // endregion + + // region Long64 (0x0060-0x007F) + /** + * L_ADD Opcode: Represents the long64 addition operation in the virtual machine. + *

    This opcode is implemented by the {@link LAddCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two long64 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
    2. + *
    3. Performs the addition operation on these two long64s.
    4. + *
    5. Pushes the result of the addition back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic long64 addition tasks.

    + */ + public static final int L_ADD = 0x0060; + /** + * L_SUB Opcode: Represents the long64 subtraction operation in the virtual machine. + *

    This opcode is implemented by the {@link LSubCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two long64 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
    2. + *
    3. Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
    4. + *
    5. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic long64 subtraction tasks.

    + */ + public static final int L_SUB = 0x0061; + /** + * L_MUL Opcode: Represents the long64 multiplication operation in the virtual machine. + *

    This opcode is implemented by the {@link LMulCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two long64 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
    2. + *
    3. Performs the multiplication operation on these two long64s (i.e., firstOperand * secondOperand).
    4. + *
    5. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic long64 multiplication tasks.

    + */ + public static final int L_MUL = 0x0062; + /** + * L_DIV Opcode: Represents the long64 division operation in the virtual machine. + *

    This opcode is implemented by the {@link LDivCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two long64 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
    2. + *
    3. Performs the division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
    4. + *
    5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
    6. + *
    7. Pushes the result of the division back onto the operand stack for later instructions to use.
    8. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic long64 division tasks.

    + */ + public static final int L_DIV = 0x0063; + /** + * L_MOD Opcode: Represents the long64 modulus (remainder) operation in the virtual machine. + *

    This opcode is implemented by the {@link LModCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two long64 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
    2. + *
    3. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
    4. + *
    5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
    6. + *
    7. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
    8. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic long64 modulus (remainder) tasks.

    + */ + public static final int L_MOD = 0x0064; + /** + * L_NEG Opcode: Represents the long64 negation operation in the virtual machine. + *

    This opcode is implemented by the {@link LNegCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top long64 value from the operand stack.
    2. + *
    3. Performs the negation of the popped value (i.e., -value).
    4. + *
    5. Pushes the negated result back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is typically used to negate a long64 value, making it a fundamental operation for arithmetic logic within the virtual machine.

    + */ + public static final int L_NEG = 0x0065; + /** + * L_INC Opcode: Represents the long64 increment operation for a local variable in the virtual machine. + *

    This opcode is implemented by the {@link LIncCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Retrieves the index of the local variable and the increment value from the instruction parameters.
    2. + *
    3. Gets the current value of the local variable at the specified index from the local variable store.
    4. + *
    5. Increments the local variable's value by the specified increment (i.e., + * localVariables[index] += increment).
    6. + *
    7. Updates the local variable store with the new incremented value.
    8. + *
    9. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
    10. + *
    + * + *

    This opcode is particularly useful for optimizing scenarios where a local `long64` variable, such as a counter or loop index, is frequently incremented.

    + */ + public static final int L_INC = 0x0066; + /** + * L_AND Opcode: Represents the long64 bitwise AND operation in the virtual machine. + *

    This opcode is implemented by the {@link LAndCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two long64 values from the operand stack. These values are treated as 64-bit binary representations.
    2. + *
    3. Performs the long64 bitwise AND operation on the two popped operands. The operation compares corresponding bits of both operands: + * + *
    4. + *
    5. Pushes the result of the long64 bitwise AND operation back onto the operand stack for further processing.
    6. + *
    + * + *

    This opcode is essential for low-level bit manipulation tasks.

    + */ + public static final int L_AND = 0x0067; + /** + * L_OR Opcode: Represents the long64 bitwise OR operation in the virtual machine. + *

    This opcode is implemented by the {@link LOrCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two long64 values from the operand stack. These values are treated as 64-bit binary representations.
    2. + *
    3. Performs the long64 bitwise OR operation on the two popped operands. The operation compares corresponding bits of both operands: + * + *
    4. + *
    5. Pushes the result of the long64 bitwise OR operation back onto the operand stack for further processing.
    6. + *
    + * + *

    This opcode is essential for low-level bit manipulation tasks.

    + */ + public static final int L_OR = 0x0068; + /** + * L_XOR Opcode: Represents the long64 bitwise XOR operation in the virtual machine. + *

    This opcode is implemented by the {@link LXorCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two long64 values from the operand stack. These values are treated as 64-bit binary representations.
    2. + *
    3. Performs the long64 bitwise XOR (exclusive OR) operation on the two operands: + * + *
    4. + *
    5. Pushes the result of the long64 bitwise XOR operation back onto the operand stack for further processing.
    6. + *
    + * + *

    This opcode is essential for low-level bit manipulation tasks.

    + */ + public static final int L_XOR = 0x0069; + /** + * L_PUSH Opcode: Represents a stack operation that pushes a long64 value onto the operand stack. + *

    This opcode is implemented by the {@link LPushCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the long64 value from the instruction parameters.
    2. + *
    3. Pushes the parsed long64 value onto the operand stack.
    4. *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. *
    * *

    This opcode is commonly used for:

    * */ - public static final int L_STORE = 152; - /** - * S_STORE Opcode: Represents a store operation that stores a short16 value from the operand stack into the local variable store. - *

    This opcode is implemented by the {@link SStoreCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Pops a short16 value from the operand stack.
    4. - *
    5. Stores the value into the local variable store at the specified index of the current method frame.
    6. - *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int S_STORE = 153; - /** - * B_STORE Opcode: Represents a store operation that stores a byte8 value from the operand stack into the local variable store. - *

    This opcode is implemented by the {@link BStoreCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Pops a byte8 value from the operand stack.
    4. - *
    5. Stores the value into the local variable store at the specified index of the current method frame.
    6. - *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int B_STORE = 154; - /** - * D_STORE Opcode: Represents a store operation that stores a double64 value from the operand stack into the local variable store. - *

    This opcode is implemented by the {@link DStoreCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Pops a double64 value from the operand stack.
    4. - *
    5. Stores the value into the local variable store at the specified index of the current method frame.
    6. - *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int D_STORE = 155; - /** - * F_STORE Opcode: Represents a store operation that stores a float32 value from the operand stack into the local variable store. - *

    This opcode is implemented by the {@link FStoreCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Pops a float32 value from the operand stack.
    4. - *
    5. Stores the value into the local variable store at the specified index of the current method frame.
    6. - *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int F_STORE = 156; - /** - * I_LOAD Opcode: Represents a load operation that retrieves an int32 value from the local variable store and pushes it onto the operand stack. - *

    This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Retrieves the corresponding value from the local variable store of the current method frame.
    4. - *
    5. Pushes the retrieved value onto the operand stack for subsequent operations.
    6. - *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int I_LOAD = 161; + public static final int L_PUSH = 0x006A; /** * L_LOAD Opcode: Represents a load operation that retrieves a long64 value from the local variable store and pushes it onto the operand stack. *

    This opcode is implemented by the {@link LLoadCommand} class, which defines its specific execution logic.

    @@ -1705,67 +959,283 @@ public class VMOpCode { *
  • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
  • * */ - public static final int L_LOAD = 162; + public static final int L_LOAD = 0x006B; /** - * S_LOAD Opcode: Represents a load operation that retrieves a short16 value from the local variable store and pushes it onto the operand stack. - *

    This opcode is implemented by the {@link SLoadCommand} class, which defines its specific execution logic.

    + * L_STORE Opcode: Represents a store operation that stores a long64 value from the operand stack into the local variable store. + *

    This opcode is implemented by the {@link LStoreCommand} class, which defines its specific execution logic.

    * *

    Execution Steps:

    *
      *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Retrieves the corresponding value from the local variable store of the current method frame.
    4. - *
    5. Pushes the retrieved value onto the operand stack for subsequent operations.
    6. + *
    7. Pops a long64 value from the operand stack.
    8. + *
    9. Stores the value into the local variable store at the specified index of the current method frame.
    10. *
    11. Increments the program counter (PC) to proceed with the next sequential instruction.
    12. *
    * *

    This opcode is commonly used for:

    * */ - public static final int S_LOAD = 163; + public static final int L_STORE = 0x006C; /** - * B_LOAD Opcode: Represents a load operation that retrieves a byte8 value from the local variable store and pushes it onto the operand stack. - *

    This opcode is implemented by the {@link BLoadCommand} class, which defines its specific execution logic.

    + * L_CE Opcode: Represents a conditional jump based on long64 equality. + *

    This opcode is implemented by the {@link LCECommand} class, which defines its specific execution logic.

    * *

    Execution Steps:

    *
      - *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Retrieves the corresponding value from the local variable store of the current method frame.
    4. - *
    5. Pushes the retrieved value onto the operand stack for subsequent operations.
    6. + *
    7. Parses the target instruction address from the instruction parameters.
    8. + *
    9. Pops two long64 values from the operand stack.
    10. + *
    11. Compares the two long64s for equality.
    12. + *
    13. If the long64s are equal, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    14. + *
    15. If the long64s are not equal, increments the program counter to proceed with the next sequential instruction.
    16. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int L_CE = 0x006D; + /** + * L_CNE Opcode: Represents a conditional jump based on long64 inequality. + *

    This opcode is implemented by the {@link LCNECommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two long64 values from the operand stack.
    4. + *
    5. Compares the two long64s for inequality.
    6. + *
    7. If the long64s are not equal, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the long64s are equal, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int L_CNE = 0x006E; + /** + * L_CG Opcode: Represents a conditional jump based on long64 comparison (greater than). + *

    This opcode is implemented by the {@link LCGCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two long64 values from the operand stack.
    4. + *
    5. Compares the first long64 with the second to determine if it is greater.
    6. + *
    7. If the first long64 is greater than the second, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the first long64 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int L_CG = 0x006F; + /** + * L_CGE Opcode: Represents a conditional jump based on long64 comparison (greater than or equal to). + *

    This opcode is implemented by the {@link LCGECommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two long64 values from the operand stack.
    4. + *
    5. Compares the first long64 with the second to determine if it is greater than or equal to the second long64.
    6. + *
    7. If the first long64 is greater than or equal to the second, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the first long64 is less than the second, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int L_CGE = 0x0070; + /** + * L_CL Opcode: Represents a conditional jump based on long64 comparison (less than). + *

    This opcode is implemented by the {@link LCLCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two long64 values from the operand stack.
    4. + *
    5. Compares the first long64 with the second to determine if it is less than the second long64.
    6. + *
    7. If the first long64 is less than the second, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the first long64 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int L_CL = 0x0071; + /** + * L_CLE Opcode: Represents a conditional jump based on long64 comparison (less than or equal). + *

    This opcode is implemented by the {@link LCLECommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Pops two long64 values from the operand stack.
    4. + *
    5. Compares the first long64 with the second to determine if it is less than or equal to the second long64.
    6. + *
    7. If the first long64 is less than or equal to the second, updates the program counter (PC) to the specified target address, + * effectively jumping to the target instruction.
    8. + *
    9. If the first long64 is greater than the second, increments the program counter to proceed with the next sequential instruction.
    10. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int L_CLE = 0x0072; + // endregion + + // region Float32 (0x0080-0x009F) + /** + * F_ADD Opcode: Represents the float32 addition operation in the virtual machine. + *

    This opcode is implemented by the {@link FAddCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two float32 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
    2. + *
    3. Performs the float32 addition operation on these two operands.
    4. + *
    5. Pushes the result of the addition back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic float32 addition tasks.

    + */ + public static final int F_ADD = 0x0080; + /** + * F_SUB Opcode: Represents the float32 subtraction operation in the virtual machine. + *

    This opcode is implemented by the {@link FSubCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two float32 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
    2. + *
    3. Performs the float32 subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
    4. + *
    5. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic float32 subtraction tasks.

    + */ + public static final int F_SUB = 0x0081; + /** + * F_MUL Opcode: Represents the float32 multiplication operation in the virtual machine. + *

    This opcode is implemented by the {@link FMulCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two float32 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
    2. + *
    3. Performs the float32 multiplication operation on these two operands (i.e., firstOperand * secondOperand).
    4. + *
    5. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic float32 multiplication tasks.

    + */ + public static final int F_MUL = 0x0082; + /** + * F_DIV Opcode: Represents the float32 division operation in the virtual machine. + *

    This opcode is implemented by the {@link FDivCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two float32 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
    2. + *
    3. Performs the float32 division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
    4. + *
    5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
    6. + *
    7. Pushes the result of the division back onto the operand stack for later instructions to use.
    8. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic float32 division tasks.

    + */ + public static final int F_DIV = 0x0083; + /** + * F_MOD Opcode: Represents the float32 modulus (remainder) operation in the virtual machine. + *

    This opcode is implemented by the {@link FModCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two float32 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
    2. + *
    3. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
    4. + *
    5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
    6. + *
    7. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
    8. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic float32 modulus (remainder) tasks.

    + */ + public static final int F_MOD = 0x0084; + /** + * F_NEG Opcode: Represents the float32 negation operation in the virtual machine. + *

    This opcode is implemented by the {@link FNegCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top float32 value from the operand stack.
    2. + *
    3. Performs the negation of the popped value (i.e., -value).
    4. + *
    5. Pushes the negated result back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is typically used to negate a float32 value, making it a fundamental operation for float32 arithmetic logic within the virtual machine.

    + */ + public static final int F_NEG = 0x0085; + /** + * F_INC Opcode: Represents the float32 increment operation for a local variable in the virtual machine. + *

    This opcode is implemented by the {@link FIncCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Retrieves the index of the local variable and the increment value from the instruction parameters.
    2. + *
    3. Gets the current value of the local variable at the specified index from the local variable store.
    4. + *
    5. Increments the local variable's value by the specified increment (i.e., + * localVariables[index] += increment).
    6. + *
    7. Updates the local variable store with the new incremented value.
    8. + *
    9. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
    10. + *
    + * + *

    This opcode is particularly useful for optimizing scenarios where a local `float32` variable, such as a counter or loop index, is frequently incremented.

    + */ + public static final int F_INC = 0x0086; + /** + * F_PUSH Opcode: Represents a stack operation that pushes a float32 value onto the operand stack. + *

    This opcode is implemented by the {@link FPushCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the float32 value from the instruction parameters.
    2. + *
    3. Pushes the parsed float32 value onto the operand stack.
    4. *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. *
    * *

    This opcode is commonly used for:

    * */ - public static final int B_LOAD = 164; - /** - * D_LOAD Opcode: Represents a load operation that retrieves a double64 value from the local variable store and pushes it onto the operand stack. - *

    This opcode is implemented by the {@link DLoadCommand} class, which defines its specific execution logic.

    - * - *

    Execution Steps:

    - *
      - *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. - *
    3. Retrieves the corresponding value from the local variable store of the current method frame.
    4. - *
    5. Pushes the retrieved value onto the operand stack for subsequent operations.
    6. - *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. - *
    - * - *

    This opcode is commonly used for:

    - * - */ - public static final int D_LOAD = 165; + public static final int F_PUSH = 0x0087; /** * F_LOAD Opcode: Represents a load operation that retrieves a float32 value from the local variable store and pushes it onto the operand stack. *

    This opcode is implemented by the {@link FLoadCommand} class, which defines its specific execution logic.

    @@ -1785,30 +1255,523 @@ public class VMOpCode { *
  • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
  • * */ - public static final int F_LOAD = 166; - + public static final int F_LOAD = 0x0088; /** - * MOV Opcode: Represents a move operation that transfers a value from one local variable to another within the local variable store. - *

    This opcode is implemented by the {@link MovCommand} class, which defines its specific execution logic.

    + * F_STORE Opcode: Represents a store operation that stores a float32 value from the operand stack into the local variable store. + *

    This opcode is implemented by the {@link FStoreCommand} class, which defines its specific execution logic.

    * *

    Execution Steps:

    *
      - *
    1. Parses the source and destination indices from the instruction parameters.
    2. - *
    3. Retrieves the value from the local variable store at the source index.
    4. - *
    5. Stores the retrieved value into the destination index of the local variable store.
    6. + *
    7. Retrieves the index for the local variable from the instruction parameters.
    8. + *
    9. Pops a float32 value from the operand stack.
    10. + *
    11. Stores the value into the local variable store at the specified index of the current method frame.
    12. *
    13. Increments the program counter (PC) to proceed with the next sequential instruction.
    14. *
    * *

    This opcode is commonly used for:

    * */ - public static final int MOV = 171; + public static final int F_STORE = 0x0089; + + public static final int F_CE = 0x008A; + public static final int F_CNE = 0x008B; + public static final int F_CG = 0x008C; + public static final int F_CGE = 0x008D; + public static final int F_CL = 0x008E; + public static final int F_CLE = 0x008F; + // endregion - // region 6. Function Call + + // region Double64 (0x00A0-0x00BF) + /** + * D_ADD Opcode: Represents the double64 precision floating-point addition operation in the virtual machine. + *

    This opcode is implemented by the {@link DAddCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two double64 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
    2. + *
    3. Performs the double64 precision floating-point addition operation on these two operands.
    4. + *
    5. Pushes the result of the addition back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic double64 precision floating-point addition tasks.

    + */ + public static final int D_ADD = 0x00A0; + /** + * D_SUB Opcode: Represents the double64 precision floating-point subtraction operation in the virtual machine. + *

    This opcode is implemented by the {@link DSubCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two double64 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).
    2. + *
    3. Performs the double64 precision floating-point subtraction operation by subtracting the subtrahend from the minuend (i.e., minuend - subtrahend).
    4. + *
    5. Pushes the result of the subtraction back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic double64 precision floating-point subtraction tasks.

    + */ + public static final int D_SUB = 0x00A1; + /** + * D_MUL Opcode: Represents the double64 precision floating-point multiplication operation in the virtual machine. + *

    This opcode is implemented by the {@link DMulCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two double64 values from the operand stack (the first value popped is the second operand, and the second value popped is the first operand).
    2. + *
    3. Performs the double64 precision floating-point multiplication operation on these two operands (i.e., firstOperand * secondOperand).
    4. + *
    5. Pushes the result of the multiplication back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic double64 precision floating-point multiplication tasks.

    + */ + public static final int D_MUL = 0x00A2; + /** + * D_DIV Opcode: Represents the double64 precision floating-point division operation in the virtual machine. + *

    This opcode is implemented by the {@link DDivCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two double64 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
    2. + *
    3. Performs the double64 precision floating-point division operation by dividing the dividend by the divisor (i.e., dividend / divisor).
    4. + *
    5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
    6. + *
    7. Pushes the result of the division back onto the operand stack for later instructions to use.
    8. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic double64 precision floating-point division tasks.

    + */ + public static final int D_DIV = 0x00A3; + /** + * D_MOD Opcode: Represents the double64 precision floating-point modulus (remainder) operation in the virtual machine. + *

    This opcode is implemented by the {@link DModCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top two double64 values from the operand stack (the first value popped is the divisor, and the second value popped is the dividend).
    2. + *
    3. Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e., dividend % divisor).
    4. + *
    5. Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
    6. + *
    7. Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
    8. + *
    + * + *

    This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, + * primarily used to handle basic double64 precision floating-point modulus (remainder) tasks.

    + */ + public static final int D_MOD = 0x00A4; + /** + * D_NEG Opcode: Represents the double64 precision floating-point negation operation in the virtual machine. + *

    This opcode is implemented by the {@link DNegCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pops the top double64 value from the operand stack.
    2. + *
    3. Performs the negation of the popped value (i.e., -value).
    4. + *
    5. Pushes the negated result back onto the operand stack for later instructions to use.
    6. + *
    + * + *

    This opcode is typically used to negate a double64 precision floating-point value, making it a fundamental operation for double64 precision arithmetic logic within the virtual machine.

    + */ + public static final int D_NEG = 0x00A5; + /** + * D_INC Opcode: Represents the double64 increment operation for a local variable in the virtual machine. + *

    This opcode is implemented by the {@link DIncCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Retrieves the index of the local variable and the increment value from the instruction parameters.
    2. + *
    3. Gets the current value of the local variable at the specified index from the local variable store.
    4. + *
    5. Increments the local variable's value by the specified increment (i.e., + * localVariables[index] += increment).
    6. + *
    7. Updates the local variable store with the new incremented value.
    8. + *
    9. Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
    10. + *
    + * + *

    This opcode is particularly useful for optimizing scenarios where a local `double64` variable, such as a counter or loop index, is frequently incremented.

    + */ + public static final int D_INC = 0x00A6; + /** + * D_PUSH Opcode: Represents a stack operation that pushes a double64 value onto the operand stack. + *

    This opcode is implemented by the {@link DPushCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the double64 value from the instruction parameters.
    2. + *
    3. Pushes the parsed double64 value onto the operand stack.
    4. + *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int D_PUSH = 0x00A7; + /** + * D_LOAD Opcode: Represents a load operation that retrieves a double64 value from the local variable store and pushes it onto the operand stack. + *

    This opcode is implemented by the {@link DLoadCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. + *
    3. Retrieves the corresponding value from the local variable store of the current method frame.
    4. + *
    5. Pushes the retrieved value onto the operand stack for subsequent operations.
    6. + *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int D_LOAD = 0x00A8; + /** + * D_STORE Opcode: Represents a store operation that stores a double64 value from the operand stack into the local variable store. + *

    This opcode is implemented by the {@link DStoreCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Retrieves the index for the local variable from the instruction parameters.
    2. + *
    3. Pops a double64 value from the operand stack.
    4. + *
    5. Stores the value into the local variable store at the specified index of the current method frame.
    6. + *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int D_STORE = 0x00A9; + + public static final int D_CE = 0x00AA; + public static final int D_CNE = 0x00AB; + public static final int D_CG = 0x00AC; + public static final int D_CGE = 0x00AD; + public static final int D_CL = 0x00AE; + public static final int D_CLE = 0x00AF; + + // endregion + + // region Type Conversion (0x00C0-0x00DF) + /** + * I2L Opcode: Represents the type conversion operation from int32 to long64 in the virtual machine. + *

    This opcode is implemented by the {@link I2LCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top int32 value from the operand stack.
    2. + *
    3. Convert the int32 value to a long64 value.
    4. + *
    5. Push the converted long64 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is commonly used to widen an int32 value to a long64 type to accommodate larger numeric ranges.

    + */ + public static final int I2L = 0x00C0; + /** + * I2S Opcode: Represents the type conversion operation from int32 to short16 in the virtual machine. + *

    This opcode is implemented by the {@link I2SCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top int32 value from the operand stack.
    2. + *
    3. Convert the int32 value to a short16 value (this may involve truncation).
    4. + *
    5. Push the converted short16 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is typically used to narrow an int32 value to a short16 type when a smaller data representation is needed.

    + */ + public static final int I2S = 0x00C1; + /** + * I2B Opcode: Represents the type conversion operation from int32 to byte8 in the virtual machine. + *

    This opcode is implemented by the {@link I2BCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top int32 value from the operand stack.
    2. + *
    3. Convert the int32 value to a byte8 value (this may involve truncation).
    4. + *
    5. Push the converted byte8 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to narrow an int32 value to a byte8 type, suitable when a smaller numeric type is required.

    + */ + public static final int I2B = 0x00C2; + /** + * I2D Opcode: Represents the type conversion operation from int32 to double64 in the virtual machine. + *

    This opcode is implemented by the {@link I2DCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top int32 value from the operand stack.
    2. + *
    3. Convert the int32 value to a double64 value.
    4. + *
    5. Push the converted double64 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to widen an int32 value to a double64 type, providing high-precision floating-point calculations.

    + */ + public static final int I2D = 0x00C3; + /** + * I2F Opcode: Represents the type conversion operation from int32 to float32 in the virtual machine. + *

    This opcode is implemented by the {@link I2FCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top int32 value from the operand stack.
    2. + *
    3. Convert the int32 value to a float32 value.
    4. + *
    5. Push the converted float32 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to convert an int32 value to a float32 type when floating-point arithmetic is required.

    + */ + public static final int I2F = 0x00C4; + /** + * L2I Opcode: Represents the type conversion operation from long64 to int32 in the virtual machine. + *

    This opcode is implemented by the {@link L2ICommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top long64 value from the operand stack.
    2. + *
    3. Convert the long64 value to an int32 value (this may involve truncation).
    4. + *
    5. Push the converted int32 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is typically used to narrow a long64 value to an int32 type for further integer operations.

    + */ + public static final int L2I = 0x00C5; + /** + * L2D Opcode: Represents the type conversion operation from long64 to double64 in the virtual machine. + *

    This opcode is implemented by the {@link L2DCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top long64 value from the operand stack.
    2. + *
    3. Convert the long64 value to a double64 value.
    4. + *
    5. Push the converted double64 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to widen a long64 value to a double64 type for high-precision floating-point computations.

    + */ + public static final int L2D = 0x00C6; + /** + * L2F Opcode: Represents the type conversion operation from long64 to float32 in the virtual machine. + *

    This opcode is implemented by the {@link L2FCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top long64 value from the operand stack.
    2. + *
    3. Convert the long64 value to a float32 value.
    4. + *
    5. Push the converted float32 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to convert a long64 value to a float32 type, typically for floating-point arithmetic involving long values.

    + */ + public static final int L2F = 0x00C7; + /** + * F2I Opcode: Represents the type conversion operation from float32 to int32 in the virtual machine. + *

    This opcode is implemented by the {@link F2ICommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top float32 value from the operand stack.
    2. + *
    3. Convert the float32 value to an int32 value (this may involve truncation).
    4. + *
    5. Push the converted int32 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to convert a float32 value to an int32 type for further integer-based operations or comparisons.

    + */ + public static final int F2I = 0x00C8; + /** + * F2L Opcode: Represents the type conversion operation from float32 to long64 in the virtual machine. + *

    This opcode is implemented by the {@link F2LCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top float32 value from the operand stack.
    2. + *
    3. Convert the float32 value to a long64 value.
    4. + *
    5. Push the converted long64 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to widen a float32 value to a long64 type, which is useful when operations require a larger numeric range.

    + */ + public static final int F2L = 0x00C9; + /** + * F2D Opcode: Represents the type conversion operation from float32 to double64 in the virtual machine. + *

    This opcode is implemented by the {@link F2DCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top float32 value from the operand stack.
    2. + *
    3. Convert the float32 value to a double64 value.
    4. + *
    5. Push the converted double64 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to promote a float32 value to a double64 type, thereby increasing precision for floating-point computations.

    + */ + public static final int F2D = 0x00CA; + /** + * D2I Opcode: Represents the type conversion operation from double64 to int32 in the virtual machine. + *

    This opcode is implemented by the {@link D2ICommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top double64 value from the operand stack.
    2. + *
    3. Convert the double64 value to an int32 value (this may involve truncation).
    4. + *
    5. Push the converted int32 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to narrow a double64 value to an int32 type for further integer-based processing.

    + */ + public static final int D2I = 0x00CB; + /** + * D2L Opcode: Represents the type conversion operation from double64 to long64 in the virtual machine. + *

    This opcode is implemented by the {@link D2LCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top double64 value from the operand stack.
    2. + *
    3. Convert the double64 value to a long64 value (this may involve truncation).
    4. + *
    5. Push the converted long64 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to narrow a double64 value to a long64 type, which can then be used for integer operations.

    + */ + public static final int D2L = 0x00CC; + /** + * D2F Opcode: Represents the type conversion operation from double64 to float32 in the virtual machine. + *

    This opcode is implemented by the {@link D2FCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top double64 value from the operand stack.
    2. + *
    3. Convert the double64 value to a float32 value.
    4. + *
    5. Push the converted float32 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to narrow a double64 value to a float32 type when lower precision floating-point arithmetic is acceptable.

    + */ + public static final int D2F = 0x00CD; + /** + * S2I Opcode: Represents the type conversion operation from short16 to int32 in the virtual machine. + *

    This opcode is implemented by the {@link S2ICommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top short16 value from the operand stack.
    2. + *
    3. Convert the short16 value to an int32 value.
    4. + *
    5. Push the converted int32 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to widen a short16 value to an int32 type, facilitating subsequent integer arithmetic or comparison operations.

    + */ + public static final int S2I = 0x00CE; + /** + * B2I Opcode: Represents the type conversion operation from byte8 to int32 in the virtual machine. + *

    This opcode is implemented by the {@link B2ICommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Pop the top byte8 value from the operand stack.
    2. + *
    3. Convert the byte8 value to an int32 value.
    4. + *
    5. Push the converted int32 value back onto the operand stack for subsequent operations.
    6. + *
    + * + *

    This opcode is used to widen a byte8 value to an int32 type to ensure compatibility with integer-based operations.

    + */ + public static final int B2I = 0x00CF; + // endregion + + // region Stack Control (0x0100-0x01FF) + /** + * POP Opcode: Represents a stack operation that removes the top element from the operand stack. + *

    This opcode is implemented by the {@link PopCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Removes (pops) the top element from the operand stack.
    2. + *
    3. Discards the popped value, as it is not stored or used further.
    4. + *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int POP = 0x0100; + /** + * DUP Opcode: Represents a stack operation that duplicates the top element of the operand stack. + *

    This opcode is implemented by the {@link DupCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Retrieves the top element from the operand stack.
    2. + *
    3. Duplicates the top value and pushes it back onto the stack.
    4. + *
    5. Increments the program counter (PC) to proceed with the next sequential instruction.
    6. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int DUP = 0x0101; + /** + * SWAP Opcode: Represents a stack operation that swaps the top two values of the operand stack. + *

    This opcode is implemented by the {@link SwapCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Ensures that there are at least two elements on the operand stack.
    2. + *
    3. Pops the two topmost values from the stack.
    4. + *
    5. Pushes the two values back onto the stack in reversed order.
    6. + *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int SWAP = 0x0102; + // endregion + + // region Flow Control (0x0200-0x02FF) + /** + * JUMP Opcode: Represents an unconditional jump to a target instruction address. + *

    This opcode is implemented by the {@link JumpCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the target instruction address from the instruction parameters.
    2. + *
    3. Validates the target address to ensure it is a non-negative int32.
    4. + *
    5. If the target address is valid (greater than or equal to 0), updates the program counter (PC) to the specified target address, + * effectively skipping all intermediate instructions.
    6. + *
    7. If the target address is invalid (less than 0), logs an error message and halts execution by returning an invalid value (typically -1).
    8. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int JUMP = 0x0200; /** * CALL Opcode: Represents a function or subroutine call operation that transfers control to a specified function address. *

    This opcode is implemented by the {@link CallCommand} class, which defines its specific execution logic.

    @@ -1828,7 +1791,7 @@ public class VMOpCode { *
  • Facilitating modular and reusable code execution by enabling jumps to specific function addresses.
  • * */ - public static final int CALL = 201; + public static final int CALL = 0x0201; /** * RET Opcode: Represents a return operation that transfers control back to the calling method by restoring the saved return address. *

    This opcode is implemented by the {@link RetCommand} class, which defines its specific execution logic.

    @@ -1848,7 +1811,33 @@ public class VMOpCode { *
  • Cleaning up the local variables of the completed method to maintain memory consistency.
  • * */ - public static final int RET = 202; + public static final int RET = 0x0202; + // endregion + + // region Register Control (0x0300-0x03FF) + /** + * MOV Opcode: Represents a move operation that transfers a value from one local variable to another within the local variable store. + *

    This opcode is implemented by the {@link MovCommand} class, which defines its specific execution logic.

    + * + *

    Execution Steps:

    + *
      + *
    1. Parses the source and destination indices from the instruction parameters.
    2. + *
    3. Retrieves the value from the local variable store at the source index.
    4. + *
    5. Stores the retrieved value into the destination index of the local variable store.
    6. + *
    7. Increments the program counter (PC) to proceed with the next sequential instruction.
    8. + *
    + * + *

    This opcode is commonly used for:

    + * + */ + public static final int MOV = 0x0300; + // endregion + + // region System Control (0x0400-0x04FF) /** * HALT Opcode: Represents a termination operation that stops the execution of the virtual machine. *

    This opcode is implemented by the {@link HaltCommand} class, which defines its specific execution logic.

    @@ -1865,7 +1854,9 @@ public class VMOpCode { *
  • Serving as the final instruction in a program to indicate normal completion.
  • * */ - public static final int HALT = 255; + public static final int HALT = 0x0400; + public static final int SYSCALL = 0x0401; + public static final int DEBUG_TRAP = 0x0402; // endregion /** @@ -1875,4 +1866,4 @@ public class VMOpCode { public VMOpCode() { // Empty constructor } -} +} \ No newline at end of file