From 64e5d4c4016660f44b584a10d65dc1073f9afeb5 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 26 Jun 2025 12:14:47 +0800 Subject: [PATCH 01/15] =?UTF-8?q?style=EF=BC=9A=E8=B0=83=E6=95=B4=E9=97=B4?= =?UTF-8?q?=E8=B7=9D=20VMOpCode.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jcnc/snow/vm/engine/VMOpCode.java | 124 +++++++----------- 1 file changed, 47 insertions(+), 77 deletions(-) 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 5080fee..f5e8762 100644 --- a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java +++ b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java @@ -47,8 +47,8 @@ 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–80) - // region 1.1 int32 (1-10) + // region 1. Arithmetic Operations (1–100) + // region 1.1 int32 (0-9) /** * 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.

@@ -63,7 +63,7 @@ public class VMOpCode { *

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 = 1; + public static final int I_ADD = 0; /** * 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.

@@ -78,7 +78,7 @@ public class VMOpCode { *

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 = 2; + public static final int I_SUB = 1; /** * 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.

@@ -93,7 +93,7 @@ public class VMOpCode { *

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 = 3; + public static final int I_MUL = 2; /** * 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.

@@ -109,7 +109,7 @@ public class VMOpCode { *

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 = 4; + public static final int I_DIV = 3; /** * 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.

@@ -125,7 +125,7 @@ public class VMOpCode { *

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 = 5; + public static final int I_MOD = 4; /** * 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.

@@ -142,8 +142,7 @@ public class VMOpCode { * *

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 = 6; - + public static final int I_INC = 5; /** * 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.

@@ -157,10 +156,10 @@ public class VMOpCode { * *

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 = 7; - + public static final int I_NEG = 6; // endregion - // region 1.2 long64 (11-20) + + // 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.

@@ -175,8 +174,7 @@ public class VMOpCode { *

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 = 11; - + 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.

@@ -191,8 +189,7 @@ public class VMOpCode { *

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 = 12; - + 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.

@@ -207,8 +204,7 @@ public class VMOpCode { *

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 = 13; - + 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.

@@ -224,8 +220,7 @@ public class VMOpCode { *

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 = 14; - + 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.

@@ -241,8 +236,7 @@ public class VMOpCode { *

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 = 15; - + 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.

@@ -259,9 +253,7 @@ public class VMOpCode { * *

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 = 16; - - + 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.

@@ -275,10 +267,10 @@ public class VMOpCode { * *

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 = 17; - + public static final int L_NEG = 16; // endregion - // region 1.3 short16 (21-30) + + // 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.

@@ -293,8 +285,7 @@ public class VMOpCode { *

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 = 21; - + public static final int S_ADD = 20; /** * 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.

@@ -309,8 +300,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 = 22; - + public static final int S_SUB = 21; /** * 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.

@@ -325,8 +315,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 = 23; - + public static final int S_MUL = 22; /** * 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.

@@ -342,8 +331,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 = 24; - + public static final int S_DIV = 23; /** * 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.

@@ -359,8 +347,7 @@ 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 = 25; - + public static final int S_MOD = 24; /** * 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.

@@ -378,8 +365,7 @@ 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 = 26; - + 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.

@@ -393,9 +379,9 @@ public class VMOpCode { * *

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 = 27; - + public static final int S_NEG = 26; // endregion + // region 1.4 byte8 (31-40) /** * B_ADD Opcode: Represents the byte8 addition operation in the virtual machine. @@ -412,7 +398,6 @@ public class VMOpCode { * 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.

@@ -428,7 +413,6 @@ public class VMOpCode { * 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.

@@ -444,7 +428,6 @@ public class VMOpCode { * 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.

@@ -461,7 +444,6 @@ public class VMOpCode { * 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.

@@ -478,7 +460,6 @@ public class VMOpCode { * 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.

@@ -496,8 +477,6 @@ public class VMOpCode { *

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.

@@ -512,8 +491,8 @@ public class VMOpCode { *

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 + // region 1.5 double64 (41-50) /** * D_ADD Opcode: Represents the double64 precision floating-point addition operation in the virtual machine. @@ -530,7 +509,6 @@ public class VMOpCode { * 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.

@@ -546,7 +524,6 @@ public class VMOpCode { * 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.

@@ -562,7 +539,6 @@ public class VMOpCode { * 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.

@@ -579,7 +555,6 @@ public class VMOpCode { * 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.

@@ -596,7 +571,6 @@ public class VMOpCode { * 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.

@@ -614,7 +588,6 @@ public class VMOpCode { *

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.

@@ -629,8 +602,8 @@ public class VMOpCode { *

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. @@ -726,7 +699,6 @@ public class VMOpCode { *

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.

@@ -741,7 +713,10 @@ public class VMOpCode { *

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.

@@ -756,7 +731,6 @@ public class VMOpCode { *

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.

@@ -771,7 +745,6 @@ public class VMOpCode { *

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.

@@ -786,7 +759,6 @@ public class VMOpCode { *

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.

@@ -801,7 +773,6 @@ public class VMOpCode { *

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.

@@ -816,7 +787,6 @@ public class VMOpCode { *

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.

@@ -831,7 +801,6 @@ public class VMOpCode { *

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.

@@ -981,9 +950,8 @@ public class VMOpCode { *

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 - // endregion - // endregion // region 2. Bitwise Operations (81–90) // region 2.1 int32 (81-85) /** @@ -1507,6 +1475,8 @@ public class VMOpCode { * */ 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.

@@ -1525,10 +1495,9 @@ public class VMOpCode { *
  • Ensuring stack balance during function calls or control flow transitions.
  • * */ - - // endregion - // region 4.2 POP (121-125) 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.

    @@ -1547,9 +1516,11 @@ public class VMOpCode { *
  • Managing stack balance when performing operations that require repeated access to the same data.
  • * */ - // endregion - // region 4.3 DUP (126-130) + 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.

    @@ -1569,12 +1540,9 @@ public class VMOpCode { *
  • Ensuring proper operand placement for later instructions that depend on the order of stack elements.
  • * */ - - // endregion - // region 4.4 SWAP (131-135) public static final int SWAP = 131; - // endregion + // endregion // region 5. Memory Operations (151–166) /** @@ -1818,7 +1786,7 @@ public class VMOpCode { * */ public static final int F_LOAD = 166; - // endregion + /** * 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.

    @@ -1839,7 +1807,8 @@ public class VMOpCode { * */ public static final int MOV = 171; - // region 6. function call + // endregion + // region 6. Function Call /** * 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.

    @@ -1898,6 +1867,7 @@ public class VMOpCode { */ public static final int HALT = 255; // endregion + /** * Default constructor for creating an instance of VMOpCode. * This constructor is empty as no specific initialization is required. From 4aa1804d4409eb20876941c43666e3d75be8536b Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 26 Jun 2025 18:01:30 +0800 Subject: [PATCH 02/15] =?UTF-8?q?feat=EF=BC=9ACommand[]=20=E6=89=A9?= =?UTF-8?q?=E5=AE=B9=E5=88=B0=200x04FF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snow/vm/factories/CommandFactory.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java b/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java index 5ededd8..a548fe4 100644 --- a/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java +++ b/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java @@ -52,7 +52,7 @@ import java.util.Optional; *

    This class uses an array for fast, constant-time access to corresponding command instances.

    */ public class CommandFactory { - private static final Command[] COMMANDS = new Command[1000]; // Adjust, according to your VMOpCode range + private static final Command[] COMMANDS = new Command[0x04FF]; static { // Initialize the array with corresponding commands based on opCode values @@ -146,19 +146,19 @@ public class CommandFactory { // 3.1 JUMP (91-91) COMMANDS[VMOpCode.JUMP] = new JumpCommand(); // 91 // 3.2 int32 (92-97) - COMMANDS[VMOpCode.IC_E] = new ICECommand(); // 92 - COMMANDS[VMOpCode.IC_NE] = new ICNECommand(); // 93 - COMMANDS[VMOpCode.IC_G] = new ICGCommand(); // 94 - COMMANDS[VMOpCode.IC_GE] = new ICGECommand(); // 95 - COMMANDS[VMOpCode.IC_L] = new ICLCommand(); // 96 - COMMANDS[VMOpCode.IC_LE] = new ICLECommand(); // 97 + COMMANDS[VMOpCode.I_CE] = new ICECommand(); // 92 + COMMANDS[VMOpCode.I_CNE] = new ICNECommand(); // 93 + COMMANDS[VMOpCode.I_CG] = new ICGCommand(); // 94 + COMMANDS[VMOpCode.I_CGE] = new ICGECommand(); // 95 + COMMANDS[VMOpCode.I_CL] = new ICLCommand(); // 96 + COMMANDS[VMOpCode.I_CLE] = new ICLECommand(); // 97 // 3.3 long64 (98-103) - COMMANDS[VMOpCode.LC_E] = new LCECommand(); // 98 - COMMANDS[VMOpCode.LC_NE] = new LCNECommand(); // 99 - COMMANDS[VMOpCode.LC_G] = new LCGCommand(); // 100 - COMMANDS[VMOpCode.LC_GE] = new LCGECommand(); // 101 - COMMANDS[VMOpCode.LC_L] = new LCLCommand(); // 102 - COMMANDS[VMOpCode.LC_LE] = new LCLECommand(); // 103 + COMMANDS[VMOpCode.L_CE] = new LCECommand(); // 98 + COMMANDS[VMOpCode.L_CNE] = new LCNECommand(); // 99 + COMMANDS[VMOpCode.L_CG] = new LCGCommand(); // 100 + COMMANDS[VMOpCode.L_CGE] = new LCGECommand(); // 101 + COMMANDS[VMOpCode.L_CL] = new LCLCommand(); // 102 + COMMANDS[VMOpCode.L_CLE] = new LCLECommand(); // 103 // 4. Stack Operations (111–150) // 4.1 PUSH (111-120) From 40fc6383b11c1b7579865aaaa18581aac074a511 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 26 Jun 2025 18:02:22 +0800 Subject: [PATCH 03/15] =?UTF-8?q?style=EF=BC=9A=E7=BB=9F=E4=B8=80=E8=A7=84?= =?UTF-8?q?=E8=8C=83=20VMOpCod=20e=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../snow/compiler/backend/util/OpHelper.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/jcnc/snow/compiler/backend/util/OpHelper.java b/src/main/java/org/jcnc/snow/compiler/backend/util/OpHelper.java index 8c7bba9..4bb0993 100644 --- a/src/main/java/org/jcnc/snow/compiler/backend/util/OpHelper.java +++ b/src/main/java/org/jcnc/snow/compiler/backend/util/OpHelper.java @@ -89,18 +89,18 @@ public final class OpHelper { map.put("L_OR", Integer.toString(VMOpCode.L_OR)); map.put("L_XOR", Integer.toString(VMOpCode.L_XOR)); map.put("JUMP", Integer.toString(VMOpCode.JUMP)); - map.put("IC_E", Integer.toString(VMOpCode.IC_E)); - map.put("IC_NE", Integer.toString(VMOpCode.IC_NE)); - map.put("IC_G", Integer.toString(VMOpCode.IC_G)); - map.put("IC_GE", Integer.toString(VMOpCode.IC_GE)); - map.put("IC_L", Integer.toString(VMOpCode.IC_L)); - map.put("IC_LE", Integer.toString(VMOpCode.IC_LE)); - map.put("LC_E", Integer.toString(VMOpCode.LC_E)); - map.put("LC_NE", Integer.toString(VMOpCode.LC_NE)); - map.put("LC_G", Integer.toString(VMOpCode.LC_G)); - map.put("LC_GE", Integer.toString(VMOpCode.LC_GE)); - map.put("LC_L", Integer.toString(VMOpCode.LC_L)); - map.put("LC_LE", Integer.toString(VMOpCode.LC_LE)); + map.put("IC_E", Integer.toString(VMOpCode.I_CE)); + map.put("IC_NE", Integer.toString(VMOpCode.I_CNE)); + map.put("IC_G", Integer.toString(VMOpCode.I_CG)); + map.put("IC_GE", Integer.toString(VMOpCode.I_CGE)); + map.put("IC_L", Integer.toString(VMOpCode.I_CL)); + map.put("IC_LE", Integer.toString(VMOpCode.I_CLE)); + map.put("LC_E", Integer.toString(VMOpCode.L_CE)); + map.put("LC_NE", Integer.toString(VMOpCode.L_CNE)); + map.put("LC_G", Integer.toString(VMOpCode.L_CG)); + map.put("LC_GE", Integer.toString(VMOpCode.L_CGE)); + map.put("LC_L", Integer.toString(VMOpCode.L_CL)); + map.put("LC_LE", Integer.toString(VMOpCode.L_CLE)); map.put("I_PUSH", Integer.toString(VMOpCode.I_PUSH)); map.put("L_PUSH", Integer.toString(VMOpCode.L_PUSH)); map.put("S_PUSH", Integer.toString(VMOpCode.S_PUSH)); From 221812866337f84e61eb52d9fc1f7faf874ae656 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 26 Jun 2025 18:02:42 +0800 Subject: [PATCH 04/15] =?UTF-8?q?style=EF=BC=9A=E6=89=A9=E5=AE=B9opcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jcnc/snow/vm/engine/VMOpCode.java | 2931 ++++++++--------- 1 file changed, 1461 insertions(+), 1470 deletions(-) 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:

    + *
      + *
    • Loading constant values into the operand stack for later operations.
    • + *
    • Preparing operands for arithmetic, logical, or comparison instructions.
    • + *
    • Facilitating method calls or control flow by managing stack-based data.
    • + *
    */ - 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:

    + *
      + *
    • Loading local variables onto the operand stack for further operations or computations.
    • + *
    • Retrieving stored values that are needed for subsequent instructions, such as arithmetic or logic operations.
    • + *
    • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
    • + *
    + */ + 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:

    + *
      + *
    • Saving byte8 results or constants into method-local variables.
    • + *
    • Enabling byte-level operations and temporary storage.
    • + *
    • Transferring values from the stack to local scope in compact form.
    • + *
    + */ + 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: - *
        - *
      • Each bit in the result is set to 1 only if the corresponding bits in both operands are also 1.
      • - *
      • If either of the corresponding bits is 0, the resulting bit is 0.
      • - *
      - *
    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: - *
        - *
      • Each bit in the result is set to 1 if at least one of the corresponding bits in either operand is 1.
      • - *
      • If both corresponding bits are 0, the resulting bit is 0.
      • - *
      - *
    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: - *
        - *
      • If the corresponding bits are different, the result is 1.
      • - *
      • If the corresponding bits are the same, the result is 0.
      • - *
      - *
    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: - *
        - *
      • Each bit in the result is set to 1 only if the corresponding bits in both operands are also 1.
      • - *
      • If either of the corresponding bits is 0, the resulting bit is 0.
      • - *
      - *
    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: - *
        - *
      • Each bit in the result is set to 1 if at least one of the corresponding bits in either operand is 1.
      • - *
      • If both corresponding bits are 0, the resulting bit is 0.
      • - *
      - *
    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: - *
        - *
      • If the corresponding bits are different, the result is 1.
      • - *
      • If the corresponding bits are the same, the result is 0.
      • - *
      - *
    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:

    - *
      - *
    • Control flow management in virtual machine execution.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • - *
    • Implementing control flow structures such as if-statements and loops.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • - *
    • Implementing control flow structures such as conditional loops and if-else statements.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • - *
    • Implementing control flow structures such as greater-than conditions in loops and conditional statements.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • - *
    • Implementing control flow structures such as loops, conditional statements, and range checks.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • - *
    • Implementing control flow structures such as loops, conditional statements, and range validations.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • - *
    • Implementing control flow structures such as loops, conditional statements, and boundary checks.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • - *
    • Implementing control flow structures such as if-statements and loops.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • - *
    • Implementing control flow structures such as conditional loops and if-else statements.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • - *
    • Implementing control flow structures such as greater-than conditions in loops and conditional statements.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • - *
    • Implementing control flow structures such as loops, conditional statements, and range checks.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • - *
    • Implementing control flow structures such as loops, conditional statements, and range validations.
    • - *
    - */ - 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:

    - *
      - *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • - *
    • Implementing control flow structures such as loops, conditional statements, and boundary checks.
    • - *
    - */ - 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:

    - *
      - *
    • Loading constant values into the operand stack for later operations.
    • - *
    • Preparing operands for arithmetic, logical, or comparison instructions.
    • - *
    • Facilitating method calls or control flow by managing stack-based data.
    • - *
    - */ - 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:

    - *
      - *
    • Loading constant values into the operand stack for later operations.
    • - *
    • Preparing operands for arithmetic, logical, or comparison instructions.
    • - *
    • Facilitating method calls or control flow by managing stack-based data.
    • - *
    - */ - 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:

    + *
      + *
    • Loading local variables onto the operand stack for further operations or computations.
    • + *
    • Retrieving stored values that are needed for subsequent instructions, such as arithmetic or logic operations.
    • + *
    • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
    • + *
    + */ + 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:

    + *
      + *
    • Storing short16 values resulting from calculations or conversions.
    • + *
    • Temporarily saving data in local variables for later instructions.
    • + *
    • Supporting typed local variable storage for short values.
    • + *
    + */ + 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: + *
        + *
      • Each bit in the result is set to 1 only if the corresponding bits in both operands are also 1.
      • + *
      • If either of the corresponding bits is 0, the resulting bit is 0.
      • + *
      + *
    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: + *
        + *
      • Each bit in the result is set to 1 if at least one of the corresponding bits in either operand is 1.
      • + *
      • If both corresponding bits are 0, the resulting bit is 0.
      • + *
      + *
    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: + *
        + *
      • If the corresponding bits are different, the result is 1.
      • + *
      • If the corresponding bits are the same, the result is 0.
      • + *
      + *
    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:

    *
      - *
    • Loading constant values into the operand stack for later operations.
    • - *
    • Preparing operands for arithmetic, logical, or comparison instructions.
    • - *
    • Facilitating method calls or control flow by managing stack-based data.
    • + *
    • Loading local variables onto the operand stack for further operations or computations.
    • + *
    • Retrieving stored values that are needed for subsequent instructions, such as arithmetic or logic operations.
    • + *
    • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
    • *
    */ - 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:

    - *
      - *
    • Loading constant values into the operand stack for later operations.
    • - *
    • Preparing operands for arithmetic, logical, or comparison instructions.
    • - *
    • Facilitating method calls or control flow by managing stack-based data.
    • - *
    - */ - 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:

    - *
      - *
    • Clearing temporary or unnecessary data from the operand stack.
    • - *
    • Managing stack cleanup after operations that leave excess data.
    • - *
    • Ensuring stack balance during function calls or control flow transitions.
    • - *
    - */ - 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:

    - *
      - *
    • Preserving the top element of the operand stack for later use in later operations.
    • - *
    • Duplicating values that are needed multiple times in the execution flow.
    • - *
    • Managing stack balance when performing operations that require repeated access to the same data.
    • - *
    - */ - - 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:

    - *
      - *
    • Reversing the order of the top two elements on the stack, which may be required in certain algorithms or operations.
    • - *
    • Handling data rearrangements that require immediate swapping of operands during execution.
    • - *
    • Ensuring proper operand placement for later instructions that depend on the order of stack elements.
    • - *
    - */ - 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • + *
    • Implementing control flow structures such as if-statements and loops.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • + *
    • Implementing control flow structures such as conditional loops and if-else statements.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • + *
    • Implementing control flow structures such as greater-than conditions in loops and conditional statements.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • + *
    • Implementing control flow structures such as loops, conditional statements, and range checks.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • + *
    • Implementing control flow structures such as loops, conditional statements, and range validations.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on int32 comparison.
    • + *
    • Implementing control flow structures such as loops, conditional statements, and boundary checks.
    • + *
    + */ + 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: + *
        + *
      • Each bit in the result is set to 1 only if the corresponding bits in both operands are also 1.
      • + *
      • If either of the corresponding bits is 0, the resulting bit is 0.
      • + *
      + *
    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: + *
        + *
      • Each bit in the result is set to 1 if at least one of the corresponding bits in either operand is 1.
      • + *
      • If both corresponding bits are 0, the resulting bit is 0.
      • + *
      + *
    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: + *
        + *
      • If the corresponding bits are different, the result is 1.
      • + *
      • If the corresponding bits are the same, the result is 0.
      • + *
      + *
    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:

    *
      - *
    • Storing computed long64 values into local variables for reuse.
    • - *
    • Preserving long-type data across multiple instructions or calls.
    • - *
    • Moving data from the operand stack to a persistent method-local context.
    • + *
    • Loading constant values into the operand stack for later operations.
    • + *
    • Preparing operands for arithmetic, logical, or comparison instructions.
    • + *
    • Facilitating method calls or control flow by managing stack-based data.
    • *
    */ - 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:

    - *
      - *
    • Storing short16 values resulting from calculations or conversions.
    • - *
    • Temporarily saving data in local variables for later instructions.
    • - *
    • Supporting typed local variable storage for short values.
    • - *
    - */ - 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:

    - *
      - *
    • Saving byte8 results or constants into method-local variables.
    • - *
    • Enabling byte-level operations and temporary storage.
    • - *
    • Transferring values from the stack to local scope in compact form.
    • - *
    - */ - 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:

    - *
      - *
    • Saving double64-precision results after arithmetic or conversion operations.
    • - *
    • Ensuring floating-point values persist in method-local storage.
    • - *
    • Managing precision-critical calculations across instruction sequences.
    • - *
    - */ - 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:

    - *
      - *
    • Saving float32 results into method-local variables.
    • - *
    • Supporting floating-point local variable operations.
    • - *
    • Preserving floating-point values between instructions or calls.
    • - *
    - */ - 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:

    - *
      - *
    • Loading local variables onto the operand stack for further operations or computations.
    • - *
    • Retrieving stored values that are needed for subsequent instructions, such as arithmetic or logic operations.
    • - *
    • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
    • - *
    - */ - 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:

    *
      - *
    • Loading local variables onto the operand stack for further operations or computations.
    • - *
    • Retrieving stored values that are needed for subsequent instructions, such as arithmetic or logic operations.
    • - *
    • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
    • + *
    • Storing computed long64 values into local variables for reuse.
    • + *
    • Preserving long-type data across multiple instructions or calls.
    • + *
    • Moving data from the operand stack to a persistent method-local context.
    • *
    */ - 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • + *
    • Implementing control flow structures such as if-statements and loops.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • + *
    • Implementing control flow structures such as conditional loops and if-else statements.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • + *
    • Implementing control flow structures such as greater-than conditions in loops and conditional statements.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • + *
    • Implementing control flow structures such as loops, conditional statements, and range checks.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • + *
    • Implementing control flow structures such as loops, conditional statements, and range validations.
    • + *
    + */ + 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:

    + *
      + *
    • Conditional branching in virtual machine execution based on long64 comparison.
    • + *
    • Implementing control flow structures such as loops, conditional statements, and boundary checks.
    • + *
    + */ + 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:

    *
      - *
    • Loading local variables onto the operand stack for further operations or computations.
    • - *
    • Retrieving stored values that are needed for subsequent instructions, such as arithmetic or logic operations.
    • - *
    • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
    • + *
    • Loading constant values into the operand stack for later operations.
    • + *
    • Preparing operands for arithmetic, logical, or comparison instructions.
    • + *
    • Facilitating method calls or control flow by managing stack-based data.
    • *
    */ - 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:

    - *
      - *
    • Loading local variables onto the operand stack for further operations or computations.
    • - *
    • Retrieving stored values that are needed for subsequent instructions, such as arithmetic or logic operations.
    • - *
    • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
    • - *
    - */ - 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:

    *
      - *
    • Transferring values between local variables within a method frame.
    • - *
    • Preserving computed results by moving them to designated local variable slots.
    • - *
    • Facilitating intermediate storage of values needed for later computations.
    • + *
    • Saving float32 results into method-local variables.
    • + *
    • Supporting floating-point local variable operations.
    • + *
    • Preserving floating-point values between instructions or calls.
    • *
    */ - 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:

    + *
      + *
    • Loading constant values into the operand stack for later operations.
    • + *
    • Preparing operands for arithmetic, logical, or comparison instructions.
    • + *
    • Facilitating method calls or control flow by managing stack-based data.
    • + *
    + */ + 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:

    + *
      + *
    • Loading local variables onto the operand stack for further operations or computations.
    • + *
    • Retrieving stored values that are needed for subsequent instructions, such as arithmetic or logic operations.
    • + *
    • Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.
    • + *
    + */ + 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:

    + *
      + *
    • Saving double64-precision results after arithmetic or conversion operations.
    • + *
    • Ensuring floating-point values persist in method-local storage.
    • + *
    • Managing precision-critical calculations across instruction sequences.
    • + *
    + */ + 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:

    + *
      + *
    • Clearing temporary or unnecessary data from the operand stack.
    • + *
    • Managing stack cleanup after operations that leave excess data.
    • + *
    • Ensuring stack balance during function calls or control flow transitions.
    • + *
    + */ + 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:

    + *
      + *
    • Preserving the top element of the operand stack for later use in later operations.
    • + *
    • Duplicating values that are needed multiple times in the execution flow.
    • + *
    • Managing stack balance when performing operations that require repeated access to the same data.
    • + *
    + */ + 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:

    + *
      + *
    • Reversing the order of the top two elements on the stack, which may be required in certain algorithms or operations.
    • + *
    • Handling data rearrangements that require immediate swapping of operands during execution.
    • + *
    • Ensuring proper operand placement for later instructions that depend on the order of stack elements.
    • + *
    + */ + 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:

    + *
      + *
    • Control flow management in virtual machine execution.
    • + *
    + */ + 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:

    + *
      + *
    • Transferring values between local variables within a method frame.
    • + *
    • Preserving computed results by moving them to designated local variable slots.
    • + *
    • Facilitating intermediate storage of values needed for later computations.
    • + *
    + */ + 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 From c5169b7654a4f949be6f1223afe41d477bb71964 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 27 Jun 2025 23:11:28 +0800 Subject: [PATCH 05/15] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9=20Demo=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .run/Demo1.run.xml | 2 +- .run/Demo10.run.xml | 2 +- .run/Demo2.run.xml | 2 +- .run/Demo3.run.xml | 2 +- .run/Demo4.run.xml | 2 +- .run/Demo5.run.xml | 2 +- .run/Demo6.run.xml | 2 +- .run/Demo7.run.xml | 2 +- .run/Demo8.run.xml | 2 +- .run/Demo9.run.xml | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.run/Demo1.run.xml b/.run/Demo1.run.xml index 867e2f7..55005c8 100644 --- a/.run/Demo1.run.xml +++ b/.run/Demo1.run.xml @@ -3,7 +3,7 @@