stream = Files.walk(classesDir)) {
+ stream.filter(Files::isRegularFile)
+ .forEach(p -> {
+ try {
+ // 以 classesDir 为根的相对路径存入 zip
+ zos.putNextEntry(new ZipEntry(classesDir.relativize(p).toString()));
+ Files.copy(p, zos);
+ zos.closeEntry();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }
+ }
+ }
+ System.out.println("[package] created " + packageFile);
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/pkg/tasks/PublishTask.java b/src/main/java/org/jcnc/snow/pkg/tasks/PublishTask.java
new file mode 100644
index 0000000..310b8fa
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/pkg/tasks/PublishTask.java
@@ -0,0 +1,36 @@
+package org.jcnc.snow.pkg.tasks;
+
+import org.jcnc.snow.pkg.model.Project;
+
+/**
+ * 发布项目构件到远程仓库的任务实现。
+ *
+ * 实现 {@link Task} 接口,通常用于构建流程中的发布阶段。
+ * 当前仅输出发布提示,尚未实现实际上传功能。
+ *
+ */
+public final class PublishTask implements Task {
+
+ /** 目标项目元数据 */
+ private final Project project;
+
+ /**
+ * 创建发布任务。
+ *
+ * @param project 目标项目元数据
+ */
+ public PublishTask(Project project) {
+ this.project = project;
+ }
+
+ /**
+ * 执行发布任务。目前仅打印发布提示信息,未实现实际上传逻辑。
+ *
+ * @throws Exception 预留,未来实现上传逻辑时可能抛出异常
+ */
+ @Override
+ public void run() throws Exception {
+ // TODO: 实现上传到仓库(如 HTTP PUT/POST)
+ System.out.println("[publish] uploading artifact " + project.getArtifact() + "-" + project.getVersion());
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/pkg/tasks/RunTask.java b/src/main/java/org/jcnc/snow/pkg/tasks/RunTask.java
new file mode 100644
index 0000000..ce83966
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/pkg/tasks/RunTask.java
@@ -0,0 +1,44 @@
+package org.jcnc.snow.pkg.tasks;
+
+import org.jcnc.snow.vm.VMLauncher;
+
+/**
+ * 任务:执行已编译的 VM 字节码文件(.water)。
+ *
+ * 作为 CLI、IDE 插件或其他宿主环境启动虚拟机的统一入口,
+ * 通过调用 {@link VMLauncher#main(String[])} 启动 VM 并执行指定程序。
+ *
+ */
+public final class RunTask implements Task {
+
+ /**
+ * 传递给虚拟机的完整参数列表(第一个应为 .water 文件路径)
+ */
+ private final String[] args;
+
+ /**
+ * 创建运行任务。
+ *
+ * @param args VM 参数数组(第一个为 .water 程序路径,其后为可选参数)
+ */
+ public RunTask(String... args) {
+ this.args = args;
+ }
+
+ /**
+ * 执行运行任务。内部委托 {@link VMLauncher#main(String[])} 启动 VM。
+ *
+ * - 如果参数为空则抛出 {@link IllegalArgumentException}
+ * - 异常由虚拟机本身抛出,直接透出
+ *
+ *
+ * @throws Exception 虚拟机启动或运行期间抛出的异常
+ */
+ @Override
+ public void run() throws Exception {
+ if (args == null || args.length == 0) {
+ throw new IllegalArgumentException("VM run requires at least the program file path.");
+ }
+ VMLauncher.main(args);
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/pkg/tasks/Task.java b/src/main/java/org/jcnc/snow/pkg/tasks/Task.java
new file mode 100644
index 0000000..071fdbc
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/pkg/tasks/Task.java
@@ -0,0 +1,17 @@
+package org.jcnc.snow.pkg.tasks;
+
+/**
+ * 构建任务的通用接口,所有具体任务(如编译、打包、清理等)都应实现该接口。
+ *
+ * 用于统一不同阶段任务的生命周期与执行行为。
+ *
+ */
+public interface Task {
+
+ /**
+ * 执行具体任务的入口方法。
+ *
+ * @throws Exception 任务执行过程中出现的任意异常
+ */
+ void run() throws Exception;
+}
diff --git a/src/main/java/org/jcnc/snow/pkg/utils/SnowExample.java b/src/main/java/org/jcnc/snow/pkg/utils/SnowExample.java
new file mode 100644
index 0000000..ffd18d1
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/pkg/utils/SnowExample.java
@@ -0,0 +1,58 @@
+package org.jcnc.snow.pkg.utils;
+
+/**
+ * 示例模块模板工具类,提供 main.snow 的标准示例代码字符串。
+ *
+ * 用于项目脚手架生成或帮助用户快速上手 .snow 语言。
+ *
+ */
+public final class SnowExample {
+
+ /**
+ * 工具类构造方法,禁止实例化。
+ */
+ private SnowExample() {
+ // 工具类不允许实例化
+ }
+
+ /**
+ * 获取 main.snow 示例模块的内容字符串。
+ *
+ * @return main.snow 示例模块的完整代码
+ */
+ public static String getMainModule() {
+ return """
+ module: Math
+ function: main
+ parameter:
+ return_type: int
+ body:
+ Math.factorial(6)
+ return 0
+ end body
+ end function
+
+ function: factorial
+ parameter:
+ declare n: int
+ return_type: int
+ body:
+ declare num1: int = 1
+ loop:
+ initializer:
+ declare counter:int = 1
+ condition:
+ counter <= n
+ update:
+ counter = counter + 1
+ body:
+ num1 = num1 * counter
+ end body
+ end loop
+ return num1
+ end body
+ end function
+ end module
+ """;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/VMLauncher.java b/src/main/java/org/jcnc/snow/vm/VMLauncher.java
index bbcfca8..345d9d1 100644
--- a/src/main/java/org/jcnc/snow/vm/VMLauncher.java
+++ b/src/main/java/org/jcnc/snow/vm/VMLauncher.java
@@ -44,6 +44,6 @@ public class VMLauncher {
*/
public static void main(String[] args) {
// Call the method that initializes and runs the VM in DEBUG mode
- initializeAndRunVM(args, VMMode.DEBUG);
+ initializeAndRunVM(args, VMMode.RUN);
}
}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/function/CallCommand.java b/src/main/java/org/jcnc/snow/vm/commands/flow/control/CallCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/function/CallCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/flow/control/CallCommand.java
index a384570..befbfea 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/function/CallCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/flow/control/CallCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.function;
+package org.jcnc.snow.vm.commands.flow.control;
import org.jcnc.snow.vm.engine.VMMode;
import org.jcnc.snow.vm.interfaces.Command;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/all/JumpCommand.java b/src/main/java/org/jcnc/snow/vm/commands/flow/control/JumpCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/control/all/JumpCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/flow/control/JumpCommand.java
index 63418da..7f53890 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/all/JumpCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/flow/control/JumpCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.control.all;
+package org.jcnc.snow.vm.commands.flow.control;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.utils.LoggingUtils;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/function/RetCommand.java b/src/main/java/org/jcnc/snow/vm/commands/flow/control/RetCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/function/RetCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/flow/control/RetCommand.java
index af37032..f2190fd 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/function/RetCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/flow/control/RetCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.function;
+package org.jcnc.snow.vm.commands.flow.control;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.*;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/all/MovCommand.java b/src/main/java/org/jcnc/snow/vm/commands/register/control/MovCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/all/MovCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/register/control/MovCommand.java
index dd0b11b..2c1e62b 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/all/MovCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/register/control/MovCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.all;
+package org.jcnc.snow.vm.commands.register.control;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/all/DupCommand.java b/src/main/java/org/jcnc/snow/vm/commands/stack/control/DupCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/all/DupCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/stack/control/DupCommand.java
index 8d0d1f8..4a45c8a 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/all/DupCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/stack/control/DupCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.all;
+package org.jcnc.snow.vm.commands.stack.control;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/all/PopCommand.java b/src/main/java/org/jcnc/snow/vm/commands/stack/control/PopCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/all/PopCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/stack/control/PopCommand.java
index fe00f9d..fbc89e7 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/all/PopCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/stack/control/PopCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.all;
+package org.jcnc.snow.vm.commands.stack.control;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/all/SwapCommand.java b/src/main/java/org/jcnc/snow/vm/commands/stack/control/SwapCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/all/SwapCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/stack/control/SwapCommand.java
index 1f27318..5d89bea 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/all/SwapCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/stack/control/SwapCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.all;
+package org.jcnc.snow.vm.commands.stack.control;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/vm/HaltCommand.java b/src/main/java/org/jcnc/snow/vm/commands/system/control/HaltCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/vm/HaltCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/system/control/HaltCommand.java
index 19e4d5d..06a5da4 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/vm/HaltCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/system/control/HaltCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.vm;
+package org.jcnc.snow.vm.commands.system.control;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.utils.LoggingUtils;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BAddCommand.java
similarity index 96%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BAddCommand.java
index b05f809..7da2644 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BAddCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -50,7 +50,7 @@ public class BAddCommand implements Command {
byte a = (byte) operandStack.pop();
// Perform the addition and push the result back onto the stack
- operandStack.push(a + b);
+ operandStack.push((byte)(a + b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BAndCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BAndCommand.java
new file mode 100644
index 0000000..8eb94c9
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BAndCommand.java
@@ -0,0 +1,56 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+
+/**
+ * The BAndCommand class implements the {@link Command} interface and represents the byte8 bitwise AND (`&`) operation command.
+ * This class performs a byte8 bitwise AND operation in the virtual machine by popping the top two values from the stack,
+ * computing their byte8 bitwise AND operation, and then pushing the result back onto the stack. It is a basic operation command within the virtual machine.
+ *
+ * Specific behavior:
+ *
+ * - Pops two operands from the virtual machine stack.
+ * - Performs the byte8 bitwise AND (`&`) operation.
+ * - Pushes the result back onto the virtual machine stack.
+ *
+ */
+public class BAndCommand implements Command {
+ /**
+ * Default constructor for creating an instance of {@code BAndCommand}.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BAndCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * @param operandStack The virtual machine's operand stack manager, responsible for pushing and popping values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables.
+ * @param callStack The virtual machine's call stack, used for managing method calls and returns.
+ * @return The updated program counter-value, typically `currentPC + 1` unless a control flow instruction is executed.
+ * @throws IllegalStateException if there are not enough operands on the stack to perform the operation.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Ensure the stack has at least two operands
+ if (operandStack.size() < 2) {
+ throw new IllegalStateException("Not enough operands on the stack for BAND operation.");
+ }
+
+ // Pop the top two operands from the stack
+ final byte b = (byte) operandStack.pop();
+ final byte a = (byte) operandStack.pop();
+
+ // Perform the byte8 bitwise AND operation and push the result back onto the stack
+ operandStack.push((byte)(a & b));
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCECommand.java
new file mode 100644
index 0000000..d60839f
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The BCECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if they are equal, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two byte8 from the virtual machine stack.
+ * - If the two byte8 are equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class BCECommand implements Command {
+ /**
+ * Default constructor for creating an instance of BCECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BCECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ byte b = (byte) operandStack.pop();
+ byte a = (byte) operandStack.pop();
+
+ // If the operands are equal, jump to the target command
+ if (a == b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCGCommand.java
new file mode 100644
index 0000000..bf12f76
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The BCGCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two byte8 from the virtual machine stack.
+ * - If the first byte8 is greater than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class BCGCommand implements Command {
+ /**
+ * Default constructor for creating an instance of BCGCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BCGCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ byte b = (byte) operandStack.pop();
+ byte a = (byte) operandStack.pop();
+
+ // If the first operand is greater than the second, jump to the target command
+ if (a > b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCGECommand.java
new file mode 100644
index 0000000..6173eae
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The BCGECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two byte8 from the virtual machine stack.
+ * - If the first byte8 is greater than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class BCGECommand implements Command {
+ /**
+ * Default constructor for creating an instance of BCGECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BCGECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ byte b = (byte) operandStack.pop();
+ byte a = (byte) operandStack.pop();
+
+ // If the first operand is greater than or equal to the second, jump to the target command
+ if (a >= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCLCommand.java
new file mode 100644
index 0000000..a7cf1cb
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The BCLCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two byte8 from the virtual machine stack.
+ * - If the first byte8 is less than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class BCLCommand implements Command {
+ /**
+ * Default constructor for creating an instance of BCLCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BCLCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ byte b = (byte) operandStack.pop();
+ byte a = (byte) operandStack.pop();
+
+ // If the first operand is less than the second, jump to the target command
+ if (a < b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCLECommand.java
new file mode 100644
index 0000000..e4a3aa5
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The BCLECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two byte8 from the virtual machine stack.
+ * - If the first byte8 is less than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class BCLECommand implements Command {
+ /**
+ * Default constructor for creating an instance of BCLECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BCLECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ byte b = (byte) operandStack.pop();
+ byte a = (byte) operandStack.pop();
+
+ // If the first operand is less than or equal to the second, jump to the target command
+ if (a <= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCNECommand.java
new file mode 100644
index 0000000..497b6c4
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BCNECommand.java
@@ -0,0 +1,77 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The BCNECommand class implements the {@link Command} interface and represents a conditional jump command
+ * in the virtual machine that triggers if two values are not equal.
+ *
+ * Specific behavior:
+ *
+ * - Pops two byte8 from the virtual machine stack.
+ * - If the two byte8 are not equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class BCNECommand implements Command {
+ /**
+ * Default constructor for creating an instance of BCNECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BCNECommand() {
+
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ byte b = (byte) operandStack.pop();
+ byte a = (byte) operandStack.pop();
+
+ // If the operands are not equal, jump to the target command
+ if (a != b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BDivCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BDivCommand.java
index ad24912..b71abb7 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BDivCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -56,7 +56,7 @@ public class BDivCommand implements Command {
}
// Perform the division and push the result back onto the stack
- operandStack.push(a / b);
+ operandStack.push((byte)(a / b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BIncCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BIncCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BIncCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BIncCommand.java
index 8d2dd72..c7fa3e4 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BIncCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BIncCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/byte8/BLoadCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BLoadCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/byte8/BLoadCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BLoadCommand.java
index c42e645..bf93d12 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/byte8/BLoadCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BLoadCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BModCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BModCommand.java
index 88b12bd..9a4747b 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BModCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -50,7 +50,7 @@ public class BModCommand implements Command {
byte a = (byte) operandStack.pop();
// Perform the modulus operation and push the result back onto the stack
- operandStack.push(a % b);
+ operandStack.push((byte)(a % b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BMulCommand.java
similarity index 96%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BMulCommand.java
index e5de63a..8f0bc7d 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BMulCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -50,7 +50,7 @@ public class BMulCommand implements Command {
byte a = (byte) operandStack.pop();
// Perform the multiplication and push the result back onto the stack
- operandStack.push(a * b);
+ operandStack.push((byte)(a * b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BNegCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BNegCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BNegCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BNegCommand.java
index d6b67e2..5f41f27 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BNegCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BNegCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BOrCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BOrCommand.java
new file mode 100644
index 0000000..e29aaae
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BOrCommand.java
@@ -0,0 +1,56 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+
+/**
+ * The {@code BOrCommand} class implements the {@link Command} interface and represents the byte8 bitwise OR (`|`) operation command.
+ * This class performs a byte8 bitwise OR operation in the virtual machine by popping the top two values from the stack,
+ * computing their OR, and then pushing the result back onto the stack. It is a basic operation command within the virtual machine.
+ *
+ * Operation details:
+ *
+ * - Pops two operands from the virtual machine stack.
+ * - Performs the byte8 bitwise OR (`|`) operation.
+ * - Pushes the result back onto the virtual machine stack.
+ *
+ */
+public class BOrCommand implements Command {
+ /**
+ * Default constructor for creating an instance of {@code BOrCommand}.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BOrCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing stack operations.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of method invocations.
+ * @return The updated program counter-value, typically {@code currentPC + 1}, unless a control flow instruction is executed.
+ * @throws IllegalStateException if there are not enough operands on the stack to perform the operation.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Ensure the stack has at least two operands
+ if (operandStack.size() < 2) {
+ throw new IllegalStateException("Not enough operands on the stack for BOR operation.");
+ }
+
+ // Pop the top two operands from the stack
+ final byte b = (byte) operandStack.pop();
+ final byte a = (byte) operandStack.pop();
+
+ // Perform the byte8 bitwise OR operation and push the result back onto the stack
+ operandStack.push((byte)(a | b));
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/byte8/BPushCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BPushCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/byte8/BPushCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BPushCommand.java
index 6953ff8..c2740fe 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/byte8/BPushCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BPushCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/byte8/BStoreCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BStoreCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/byte8/BStoreCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BStoreCommand.java
index 47211d1..b0cabfb 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/byte8/BStoreCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BStoreCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BSubCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BSubCommand.java
index 091cafd..7f3f22e 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BSubCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.byte8;
+package org.jcnc.snow.vm.commands.type.control.byte8;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -50,7 +50,7 @@ public class BSubCommand implements Command {
byte a = (byte) operandStack.pop();
// Perform the subtraction and push the result back onto the stack
- operandStack.push(a - b);
+ operandStack.push((byte)(a - b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BXorCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BXorCommand.java
new file mode 100644
index 0000000..478edb9
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/byte8/BXorCommand.java
@@ -0,0 +1,56 @@
+package org.jcnc.snow.vm.commands.type.control.byte8;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+
+/**
+ * The {@code BXorCommand} class implements the {@link Command} interface and represents the byte8 bitwise XOR (`^`) operation command.
+ * This class performs a byte8 bitwise XOR operation in the virtual machine by popping the top two values from the stack,
+ * computing their XOR, and then pushing the result back onto the stack. It is a basic operation command within the virtual machine.
+ *
+ * Operation details:
+ *
+ * - Pops two operands from the virtual machine stack.
+ * - Performs the byte8 bitwise XOR (`^`) operation.
+ * - Pushes the result back onto the virtual machine stack.
+ *
+ */
+public class BXorCommand implements Command {
+ /**
+ * Default constructor for creating an instance of {@code BXorCommand}.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public BXorCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing stack operations.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of method invocations.
+ * @return The updated program counter-value, typically {@code currentPC + 1}, unless a control flow instruction is executed.
+ * @throws IllegalStateException if there are not enough operands on the stack to perform the operation.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Ensure the stack has at least two operands
+ if (operandStack.size() < 2) {
+ throw new IllegalStateException("Not enough operands on the stack for BXOR operation.");
+ }
+
+ // Pop the top two operands from the stack
+ final byte b = (byte) operandStack.pop();
+ final byte a = (byte) operandStack.pop();
+
+ // Perform the byte8 bitwise XOR operation and push the result back onto the stack
+ operandStack.push((byte)(a ^ b));
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DAddCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DAddCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DAddCommand.java
index 76d8b69..470689d 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DAddCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DAddCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCECommand.java
new file mode 100644
index 0000000..a29d018
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.double64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The DCECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if they are equal, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two double64 from the virtual machine stack.
+ * - If the two double64 are equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class DCECommand implements Command {
+ /**
+ * Default constructor for creating an instance of DCECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public DCECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ double b = (double) operandStack.pop();
+ double a = (double) operandStack.pop();
+
+ // If the operands are equal, jump to the target command
+ if (a == b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCGCommand.java
new file mode 100644
index 0000000..6a35ce6
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.double64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The DCGCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two double64 from the virtual machine stack.
+ * - If the first double64 is greater than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class DCGCommand implements Command {
+ /**
+ * Default constructor for creating an instance of DCGCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public DCGCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ double b = (double) operandStack.pop();
+ double a = (double) operandStack.pop();
+
+ // If the first operand is greater than the second, jump to the target command
+ if (a > b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCGECommand.java
new file mode 100644
index 0000000..c965492
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.double64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The DCGECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two double64 from the virtual machine stack.
+ * - If the first double64 is greater than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class DCGECommand implements Command {
+ /**
+ * Default constructor for creating an instance of DCGECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public DCGECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ double b = (double) operandStack.pop();
+ double a = (double) operandStack.pop();
+
+ // If the first operand is greater than or equal to the second, jump to the target command
+ if (a >= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCLCommand.java
new file mode 100644
index 0000000..97167de
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.double64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The DCLCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two double64 from the virtual machine stack.
+ * - If the first double64 is less than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class DCLCommand implements Command {
+ /**
+ * Default constructor for creating an instance of DCLCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public DCLCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ double b = (double) operandStack.pop();
+ double a = (double) operandStack.pop();
+
+ // If the first operand is less than the second, jump to the target command
+ if (a < b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCLECommand.java
new file mode 100644
index 0000000..b43b24a
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.double64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The DCLECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two double64 from the virtual machine stack.
+ * - If the first double64 is less than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class DCLECommand implements Command {
+ /**
+ * Default constructor for creating an instance of DCLECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public DCLECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ double b = (double) operandStack.pop();
+ double a = (double) operandStack.pop();
+
+ // If the first operand is less than or equal to the second, jump to the target command
+ if (a <= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCNECommand.java
new file mode 100644
index 0000000..ff9686e
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DCNECommand.java
@@ -0,0 +1,77 @@
+package org.jcnc.snow.vm.commands.type.control.double64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The DCNECommand class implements the {@link Command} interface and represents a conditional jump command
+ * in the virtual machine that triggers if two values are not equal.
+ *
+ * Specific behavior:
+ *
+ * - Pops two double64 from the virtual machine stack.
+ * - If the two double64 are not equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class DCNECommand implements Command {
+ /**
+ * Default constructor for creating an instance of DCNECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public DCNECommand() {
+
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ double b = (double) operandStack.pop();
+ double a = (double) operandStack.pop();
+
+ // If the operands are not equal, jump to the target command
+ if (a != b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DDivCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DDivCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DDivCommand.java
index 1a70f9a..caeb802 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DDivCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DDivCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DIncCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DIncCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DIncCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DIncCommand.java
index 3f9c672..9af16d5 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DIncCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DIncCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/double64/DLoadCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DLoadCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/double64/DLoadCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DLoadCommand.java
index 9d34e21..bd240d9 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/double64/DLoadCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DLoadCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DModCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DModCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DModCommand.java
index df8cbd7..a29df4c 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DModCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DModCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DMulCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DMulCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DMulCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DMulCommand.java
index d5adb01..91957c0 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DMulCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DMulCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DNegCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DNegCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DNegCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DNegCommand.java
index 1c36841..934f017 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DNegCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DNegCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/double64/DPushCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DPushCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/double64/DPushCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DPushCommand.java
index 5245d08..b70a7b3 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/double64/DPushCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DPushCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/double64/DStoreCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DStoreCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/double64/DStoreCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DStoreCommand.java
index 7affd8f..9798043 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/double64/DStoreCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DStoreCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DSubCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DSubCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DSubCommand.java
index 72d2bda..ccb8f38 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/double64/DSubCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/double64/DSubCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.double64;
+package org.jcnc.snow.vm.commands.type.control.double64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FAddCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FAddCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FAddCommand.java
index 3c6e3cb..14ad38f 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FAddCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FAddCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCECommand.java
new file mode 100644
index 0000000..b59cd2e
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.float32;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The FCECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if they are equal, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two float32 from the virtual machine stack.
+ * - If the two float32 are equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class FCECommand implements Command {
+ /**
+ * Default constructor for creating an instance of FCECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public FCECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ float b = (float) operandStack.pop();
+ float a = (float) operandStack.pop();
+
+ // If the operands are equal, jump to the target command
+ if (a == b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCGCommand.java
new file mode 100644
index 0000000..ed49fbd
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.float32;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The FCGCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two float32 from the virtual machine stack.
+ * - If the first float32 is greater than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class FCGCommand implements Command {
+ /**
+ * Default constructor for creating an instance of FCGCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public FCGCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ float b = (float) operandStack.pop();
+ float a = (float) operandStack.pop();
+
+ // If the first operand is greater than the second, jump to the target command
+ if (a > b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCGECommand.java
new file mode 100644
index 0000000..f484bb7
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.float32;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The FCGECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two float32 from the virtual machine stack.
+ * - If the first float32 is greater than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class FCGECommand implements Command {
+ /**
+ * Default constructor for creating an instance of FCGECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public FCGECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ float b = (float) operandStack.pop();
+ float a = (float) operandStack.pop();
+
+ // If the first operand is greater than or equal to the second, jump to the target command
+ if (a >= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCLCommand.java
new file mode 100644
index 0000000..edbfa7e
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.float32;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The FCLCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two float32 from the virtual machine stack.
+ * - If the first float32 is less than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class FCLCommand implements Command {
+ /**
+ * Default constructor for creating an instance of FCLCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public FCLCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ float b = (float) operandStack.pop();
+ float a = (float) operandStack.pop();
+
+ // If the first operand is less than the second, jump to the target command
+ if (a < b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCLECommand.java
new file mode 100644
index 0000000..ed910db
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.float32;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The FCLECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two float32 from the virtual machine stack.
+ * - If the first float32 is less than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class FCLECommand implements Command {
+ /**
+ * Default constructor for creating an instance of FCLECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public FCLECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ float b = (float) operandStack.pop();
+ float a = (float) operandStack.pop();
+
+ // If the first operand is less than or equal to the second, jump to the target command
+ if (a <= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCNECommand.java
new file mode 100644
index 0000000..a02bd6a
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FCNECommand.java
@@ -0,0 +1,77 @@
+package org.jcnc.snow.vm.commands.type.control.float32;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The FCNECommand class implements the {@link Command} interface and represents a conditional jump command
+ * in the virtual machine that triggers if two values are not equal.
+ *
+ * Specific behavior:
+ *
+ * - Pops two float32 from the virtual machine stack.
+ * - If the two float32 are not equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class FCNECommand implements Command {
+ /**
+ * Default constructor for creating an instance of FCNECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public FCNECommand() {
+
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ float b = (float) operandStack.pop();
+ float a = (float) operandStack.pop();
+
+ // If the operands are not equal, jump to the target command
+ if (a != b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FDivCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FDivCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FDivCommand.java
index 5c3fbda..9e7512e 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FDivCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FDivCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FIncCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FIncCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FIncCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FIncCommand.java
index 4061ebd..94c2f2f 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FIncCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FIncCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/float32/FLoadCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FLoadCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/float32/FLoadCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FLoadCommand.java
index 7edcdb6..e0120b3 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/float32/FLoadCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FLoadCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FModCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FModCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FModCommand.java
index fc0c537..0e35b96 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FModCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FModCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FMulCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FMulCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FMulCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FMulCommand.java
index 34dfd8b..a90e951 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FMulCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FMulCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FNegCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FNegCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FNegCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FNegCommand.java
index 9b28674..89dfd4f 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FNegCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FNegCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/float32/FPushCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FPushCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/float32/FPushCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FPushCommand.java
index da6da33..cb7f6b8 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/float32/FPushCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FPushCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/float32/FStoreCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FStoreCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/float32/FStoreCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FStoreCommand.java
index 4a1ae60..5476e14 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/float32/FStoreCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FStoreCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FSubCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FSubCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FSubCommand.java
index dd73714..508a503 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/float32/FSubCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/float32/FSubCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.float32;
+package org.jcnc.snow.vm.commands.type.control.float32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IAddCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IAddCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IAddCommand.java
index 36375e3..e65c124 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IAddCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IAddCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IAndCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IAndCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IAndCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IAndCommand.java
index f43b8c6..bf49e74 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IAndCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IAndCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.bitwise.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICECommand.java
similarity index 95%
rename from src/main/java/org/jcnc/snow/vm/commands/control/int32/ICECommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICECommand.java
index 6e923af..cf35a54 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICECommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.control.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.utils.LoggingUtils;
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.module.OperandStack;
*
* Specific behavior:
*
- * - Pops two integers from the virtual machine stack.
- * - If the two integers are equal, jumps to the target command.
+ * - Pops two int32 from the virtual machine stack.
+ * - If the two int32 are equal, jumps to the target command.
* - Otherwise, the program continues with the next command.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICGCommand.java
similarity index 95%
rename from src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICGCommand.java
index a339313..12463a8 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICGCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.control.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.utils.LoggingUtils;
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.module.OperandStack;
*
* Specific behavior:
*
- * - Pops two integers from the virtual machine stack.
- * - If the first integer is greater than the second, jumps to the target command.
+ * - Pops two int32 from the virtual machine stack.
+ * - If the first int32 is greater than the second, jumps to the target command.
* - Otherwise, the program continues with the next command.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICGECommand.java
similarity index 94%
rename from src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGECommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICGECommand.java
index 3cfe02d..a689a50 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICGECommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.control.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.utils.LoggingUtils;
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.module.OperandStack;
*
* Specific behavior:
*
- * - Pops two integers from the virtual machine stack.
- * - If the first integer is greater than or equal to the second, jumps to the target command.
+ * - Pops two int32 from the virtual machine stack.
+ * - If the first int32 is greater than or equal to the second, jumps to the target command.
* - Otherwise, the program continues with the next command.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICLCommand.java
similarity index 95%
rename from src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICLCommand.java
index ec3d413..4a56631 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICLCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.control.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.utils.LoggingUtils;
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.module.OperandStack;
*
* Specific behavior:
*
- * - Pops two integers from the virtual machine stack.
- * - If the first integer is less than the second, jumps to the target command.
+ * - Pops two int32 from the virtual machine stack.
+ * - If the first int32 is less than the second, jumps to the target command.
* - Otherwise, the program continues with the next command.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICLECommand.java
similarity index 95%
rename from src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLECommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICLECommand.java
index 4e6c007..6de4e40 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICLECommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.control.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.utils.LoggingUtils;
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.module.OperandStack;
*
* Specific behavior:
*
- * - Pops two integers from the virtual machine stack.
- * - If the first integer is less than or equal to the second, jumps to the target command.
+ * - Pops two int32 from the virtual machine stack.
+ * - If the first int32 is less than or equal to the second, jumps to the target command.
* - Otherwise, the program continues with the next command.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICNECommand.java
similarity index 95%
rename from src/main/java/org/jcnc/snow/vm/commands/control/int32/ICNECommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICNECommand.java
index 08a46a9..114d75a 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICNECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ICNECommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.control.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.utils.LoggingUtils;
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.module.OperandStack;
*
* Specific behavior:
*
- * - Pops two integers from the virtual machine stack.
- * - If the two integers are not equal, jumps to the target command.
+ * - Pops two int32 from the virtual machine stack.
+ * - If the two int32 are not equal, jumps to the target command.
* - Otherwise, the program continues with the next command.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IDivCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IDivCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IDivCommand.java
index ea5c9cf..e6b0e0d 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IDivCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IDivCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IIncCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IIncCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IIncCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IIncCommand.java
index ac1c150..d95f5aa 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IIncCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IIncCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/int32/ILoadCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ILoadCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/int32/ILoadCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ILoadCommand.java
index 02a55fa..c4489bd 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/int32/ILoadCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ILoadCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IModCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IModCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IModCommand.java
index 0cb9bd0..2692321 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IModCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IModCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IMulCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IMulCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IMulCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IMulCommand.java
index a559759..41078d3 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/IMulCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IMulCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/INegCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/INegCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/INegCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/INegCommand.java
index 2746adb..ee7b9da 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/INegCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/INegCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IOrCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IOrCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IOrCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IOrCommand.java
index 2fe93e3..bc4ed11 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IOrCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IOrCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.bitwise.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/int32/IPushCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IPushCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/int32/IPushCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IPushCommand.java
index 5515e1f..0823557 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/int32/IPushCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IPushCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/int32/IStoreCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IStoreCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/int32/IStoreCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IStoreCommand.java
index 31dfb26..6101851 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/int32/IStoreCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IStoreCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/ISubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ISubCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/ISubCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ISubCommand.java
index f910e2b..530b658 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/int32/ISubCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/ISubCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IXorCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IXorCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IXorCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IXorCommand.java
index 0502e0a..a5017bc 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/bitwise/int32/IXorCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/int32/IXorCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.bitwise.int32;
+package org.jcnc.snow.vm.commands.type.control.int32;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LAddCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LAddCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LAddCommand.java
index c97a6a1..f46c34d 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LAddCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LAddCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LAndCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LAndCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LAndCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LAndCommand.java
index dd79d10..4cbf00c 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LAndCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LAndCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.bitwise.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCECommand.java
new file mode 100644
index 0000000..12a0da9
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.long64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The LCECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if they are equal, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two long64 from the virtual machine stack.
+ * - If the two long64 are equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class LCECommand implements Command {
+ /**
+ * Default constructor for creating an instance of LCECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public LCECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ long b = (long) operandStack.pop();
+ long a = (long) operandStack.pop();
+
+ // If the operands are equal, jump to the target command
+ if (a == b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCGCommand.java
new file mode 100644
index 0000000..03c7b72
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.long64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The LCGCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two long64 from the virtual machine stack.
+ * - If the first long64 is greater than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class LCGCommand implements Command {
+ /**
+ * Default constructor for creating an instance of LCGCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public LCGCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ long b = (long) operandStack.pop();
+ long a = (long) operandStack.pop();
+
+ // If the first operand is greater than the second, jump to the target command
+ if (a > b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCGECommand.java
new file mode 100644
index 0000000..c5a89d7
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.long64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The LCGECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two long64 from the virtual machine stack.
+ * - If the first long64 is greater than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class LCGECommand implements Command {
+ /**
+ * Default constructor for creating an instance of LCGECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public LCGECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ long b = (long) operandStack.pop();
+ long a = (long) operandStack.pop();
+
+ // If the first operand is greater than or equal to the second, jump to the target command
+ if (a >= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCLCommand.java
new file mode 100644
index 0000000..8db616a
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.long64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The LCLCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two long64 from the virtual machine stack.
+ * - If the first long64 is less than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class LCLCommand implements Command {
+ /**
+ * Default constructor for creating an instance of LCLCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public LCLCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ long b = (long) operandStack.pop();
+ long a = (long) operandStack.pop();
+
+ // If the first operand is less than the second, jump to the target command
+ if (a < b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCLECommand.java
new file mode 100644
index 0000000..8b86b2b
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.long64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The LCLECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two long64 from the virtual machine stack.
+ * - If the first long64 is less than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class LCLECommand implements Command {
+ /**
+ * Default constructor for creating an instance of LCLECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public LCLECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ long b = (long) operandStack.pop();
+ long a = (long) operandStack.pop();
+
+ // If the first operand is less than or equal to the second, jump to the target command
+ if (a <= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCNECommand.java
new file mode 100644
index 0000000..5bbcacd
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LCNECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.long64;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The LCNECommand class implements the {@link Command} interface and represents a conditional jump command
+ * in the virtual machine that triggers if two values are not equal.
+ *
+ * Specific behavior:
+ *
+ * - Pops two long64 from the virtual machine stack.
+ * - If the two long64 are not equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class LCNECommand implements Command {
+ /**
+ * Default constructor for creating an instance of LCNECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public LCNECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ long b = (long) operandStack.pop();
+ long a = (long) operandStack.pop();
+
+ // If the operands are not equal, jump to the target command
+ if (a != b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LDivCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LDivCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LDivCommand.java
index 7d66218..b3b1c62 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LDivCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LDivCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LIncCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LIncCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LIncCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LIncCommand.java
index 18715d3..d374e19 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LIncCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LIncCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/long64/LLoadCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LLoadCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/long64/LLoadCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LLoadCommand.java
index 411d766..f5d81e1 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/long64/LLoadCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LLoadCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LModCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LModCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LModCommand.java
index 345c2e5..e1174cf 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LModCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LModCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LMulCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LMulCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LMulCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LMulCommand.java
index b5e68aa..1d30635 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LMulCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LMulCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LNegCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LNegCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LNegCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LNegCommand.java
index e93fd1d..aea11d8 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LNegCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LNegCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LOrCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LOrCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LOrCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LOrCommand.java
index 33a9bf9..eb420d8 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LOrCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LOrCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.bitwise.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/long64/LPushCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LPushCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/long64/LPushCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LPushCommand.java
index d00b9c7..1567897 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/long64/LPushCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LPushCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/long64/LStoreCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LStoreCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/long64/LStoreCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LStoreCommand.java
index f1b5e3f..28e8b13 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/long64/LStoreCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LStoreCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LSubCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LSubCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LSubCommand.java
index f710b10..db523e6 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/long64/LSubCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LSubCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LXorCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LXorCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LXorCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LXorCommand.java
index dbce6ab..5aabcfd 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/bitwise/long64/LXorCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/long64/LXorCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.bitwise.long64;
+package org.jcnc.snow.vm.commands.type.control.long64;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SAddCommand.java
similarity index 93%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SAddCommand.java
index 4137a01..2322639 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SAddCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -46,11 +46,11 @@ public class SAddCommand implements Command {
@Override
public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
// Pop the top two operands from the stack
- Short b = (Short) operandStack.pop();
- Short a = (Short) operandStack.pop();
+ short b = (short) operandStack.pop();
+ short a = (short) operandStack.pop();
// Perform the addition and push the result back onto the stack
- operandStack.push(a + b);
+ operandStack.push((short)(a + b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SAndCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SAndCommand.java
new file mode 100644
index 0000000..e2c3d89
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SAndCommand.java
@@ -0,0 +1,56 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+
+/**
+ * The SAndCommand class implements the {@link Command} interface and represents the short16 bitwise AND (`&`) operation command.
+ * This class performs a short16 bitwise AND operation in the virtual machine by popping the top two values from the stack,
+ * computing their short16 bitwise AND operation, and then pushing the result back onto the stack. It is a basic operation command within the virtual machine.
+ *
+ * Specific behavior:
+ *
+ * - Pops two operands from the virtual machine stack.
+ * - Performs the short16 bitwise AND (`&`) operation.
+ * - Pushes the result back onto the virtual machine stack.
+ *
+ */
+public class SAndCommand implements Command {
+ /**
+ * Default constructor for creating an instance of {@code SAndCommand}.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SAndCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * @param operandStack The virtual machine's operand stack manager, responsible for pushing and popping values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables.
+ * @param callStack The virtual machine's call stack, used for managing method calls and returns.
+ * @return The updated program counter-value, typically `currentPC + 1` unless a control flow instruction is executed.
+ * @throws IllegalStateException if there are not enough operands on the stack to perform the operation.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Ensure the stack has at least two operands
+ if (operandStack.size() < 2) {
+ throw new IllegalStateException("Not enough operands on the stack for SAND operation.");
+ }
+
+ // Pop the top two operands from the stack
+ final short b = (short) operandStack.pop();
+ final short a = (short) operandStack.pop();
+
+ // Perform the short16 bitwise AND operation and push the result back onto the stack
+ operandStack.push((short)(a & b));
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCECommand.java
new file mode 100644
index 0000000..af95749
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The SCECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if they are equal, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two short16 from the virtual machine stack.
+ * - If the two short16 are equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class SCECommand implements Command {
+ /**
+ * Default constructor for creating an instance of SCECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SCECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ short b = (short) operandStack.pop();
+ short a = (short) operandStack.pop();
+
+ // If the operands are equal, jump to the target command
+ if (a == b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCGCommand.java
new file mode 100644
index 0000000..516247b
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The SCGCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two short16 from the virtual machine stack.
+ * - If the first short16 is greater than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class SCGCommand implements Command {
+ /**
+ * Default constructor for creating an instance of SCGCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SCGCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ short b = (short) operandStack.pop();
+ short a = (short) operandStack.pop();
+
+ // If the first operand is greater than the second, jump to the target command
+ if (a > b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCGECommand.java
new file mode 100644
index 0000000..2e1d0f3
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The SCGECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is greater than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two short16 from the virtual machine stack.
+ * - If the first short16 is greater than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class SCGECommand implements Command {
+ /**
+ * Default constructor for creating an instance of SCGECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SCGECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ short b = (short) operandStack.pop();
+ short a = (short) operandStack.pop();
+
+ // If the first operand is greater than or equal to the second, jump to the target command
+ if (a >= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCLCommand.java
new file mode 100644
index 0000000..8f54dd9
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The SCLCommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two short16 from the virtual machine stack.
+ * - If the first short16 is less than the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class SCLCommand implements Command {
+ /**
+ * Default constructor for creating an instance of SCLCommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SCLCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ short b = (short) operandStack.pop();
+ short a = (short) operandStack.pop();
+
+ // If the first operand is less than the second, jump to the target command
+ if (a < b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCLECommand.java
new file mode 100644
index 0000000..797ce8a
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The SCLECommand class implements the {@link Command} interface and represents a conditional jump command in the virtual machine.
+ * This class compares two values from the stack, and if the first value is less than or equal to the second, it jumps to the specified target command.
+ *
+ * Specific behavior:
+ *
+ * - Pops two short16 from the virtual machine stack.
+ * - If the first short16 is less than or equal to the second, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class SCLECommand implements Command {
+ /**
+ * Default constructor for creating an instance of SCLECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SCLECommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ short b = (short) operandStack.pop();
+ short a = (short) operandStack.pop();
+
+ // If the first operand is less than or equal to the second, jump to the target command
+ if (a <= b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCNECommand.java
new file mode 100644
index 0000000..82d3e5e
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SCNECommand.java
@@ -0,0 +1,77 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+import org.jcnc.snow.vm.utils.LoggingUtils;
+
+/**
+ * The SCNECommand class implements the {@link Command} interface and represents a conditional jump command
+ * in the virtual machine that triggers if two values are not equal.
+ *
+ * Specific behavior:
+ *
+ * - Pops two short16 from the virtual machine stack.
+ * - If the two short16 are not equal, jumps to the target command.
+ * - Otherwise, the program continues with the next command.
+ *
+ */
+public class SCNECommand implements Command {
+ /**
+ * Default constructor for creating an instance of SCNECommand.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SCNECommand() {
+
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * This method retrieves the necessary data from the virtual machine stack and local variable store based on the instruction's
+ * specific implementation, performs the operation, and updates the program counter (PC) to reflect the next instruction
+ * to be executed.
+ *
+ * The parameters provided allow the command to manipulate the operand stack, modify the local variables, and control the flow
+ * of execution by updating the program counter.
+ *
+ * The exact behavior of this method will depend on the specific instruction being executed (e.g., arithmetic, branching,
+ * function calls, etc.). For example, a `CALL` instruction will modify the call stack by pushing a new frame,
+ * while a `POP` instruction will remove an item from the operand stack.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments
+ * (such as target addresses, values, or function names). These parameters may vary based on
+ * the instruction being executed.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * This value is typically incremented after the execution of each instruction to point to the next one.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing operations on the operand stack,
+ * such as pushing, popping, and peeking values.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables during instruction execution.
+ * The store may not be used in every command but can be leveraged by instructions that require access
+ * to local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of the method invocation hierarchy. It is used by
+ * instructions that involve method calls or returns (such as `CALL` and `RETURN` instructions).
+ * @return The updated program counter-value, typically the current program counter-value incremented by 1, unless the
+ * instruction modifies control flow (such as a `JUMP` or `CALL`), in which case it may return a new address
+ * corresponding to the target of the jump or the subroutine to call.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Parse the target command address
+ int target = Integer.parseInt(parts[1]);
+
+ // Pop the two operands from the stack
+ short b = (short) operandStack.pop();
+ short a = (short) operandStack.pop();
+
+ // If the operands are not equal, jump to the target command
+ if (a != b) {
+ LoggingUtils.logInfo("Jumping to command", String.valueOf(target));
+ return target;
+ }
+
+ return currentPC + 1;
+ }
+}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SDivCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SDivCommand.java
index f14cefa..d8385a2 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SDivCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -56,7 +56,7 @@ public class SDivCommand implements Command {
}
// Perform the division and push the result back onto the stack
- operandStack.push(a / b);
+ operandStack.push((short)(a / b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SIncCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SIncCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SIncCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SIncCommand.java
index 8da3133..23fc42c 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SIncCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SIncCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/short16/SLoadCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SLoadCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/short16/SLoadCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SLoadCommand.java
index 6379837..24ddf52 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/short16/SLoadCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SLoadCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SModCommand.java
similarity index 96%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SModCommand.java
index 0047449..1a78486 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SModCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -50,7 +50,7 @@ public class SModCommand implements Command {
short a = (short) operandStack.pop();
// Perform the modulus operation and push the result back onto the stack
- operandStack.push(a % b);
+ operandStack.push((short)(a % b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SMulCommand.java
similarity index 96%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SMulCommand.java
index 1a2ac4e..49d34d7 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SMulCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -50,7 +50,7 @@ public class SMulCommand implements Command {
short a = (short) operandStack.pop();
// Perform the multiplication and push the result back onto the stack
- operandStack.push(a * b);
+ operandStack.push((short)(a * b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SNegCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SNegCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SNegCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SNegCommand.java
index 1474c50..6501380 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SNegCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SNegCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SOrCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SOrCommand.java
new file mode 100644
index 0000000..72a8844
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SOrCommand.java
@@ -0,0 +1,56 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+
+/**
+ * The {@code SOrCommand} class implements the {@link Command} interface and represents the short16 bitwise OR (`|`) operation command.
+ * This class performs a short16 bitwise OR operation in the virtual machine by popping the top two values from the stack,
+ * computing their OR, and then pushing the result back onto the stack. It is a basic operation command within the virtual machine.
+ *
+ * Operation details:
+ *
+ * - Pops two operands from the virtual machine stack.
+ * - Performs the short16 bitwise OR (`|`) operation.
+ * - Pushes the result back onto the virtual machine stack.
+ *
+ */
+public class SOrCommand implements Command {
+ /**
+ * Default constructor for creating an instance of {@code SOrCommand}.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SOrCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing stack operations.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of method invocations.
+ * @return The updated program counter-value, typically {@code currentPC + 1}, unless a control flow instruction is executed.
+ * @throws IllegalStateException if there are not enough operands on the stack to perform the operation.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Ensure the stack has at least two operands
+ if (operandStack.size() < 2) {
+ throw new IllegalStateException("Not enough operands on the stack for SOR operation.");
+ }
+
+ // Pop the top two operands from the stack
+ final short b = (short) operandStack.pop();
+ final short a = (short) operandStack.pop();
+
+ // Perform the short16 bitwise OR operation and push the result back onto the stack
+ operandStack.push((short)(a | b));
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/stack/short16/SPushCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SPushCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/stack/short16/SPushCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SPushCommand.java
index b61fbe2..77af696 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/stack/short16/SPushCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SPushCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.stack.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/memory/short16/SStoreCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SStoreCommand.java
similarity index 98%
rename from src/main/java/org/jcnc/snow/vm/commands/memory/short16/SStoreCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SStoreCommand.java
index fb5d79c..a3ea6dd 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/memory/short16/SStoreCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SStoreCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.memory.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SSubCommand.java
similarity index 96%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SSubCommand.java
index 66c3295..d16d0e0 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SSubCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.short16;
+package org.jcnc.snow.vm.commands.type.control.short16;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
@@ -50,7 +50,7 @@ public class SSubCommand implements Command {
short a = (short) operandStack.pop();
// Perform the subtraction and push the result back onto the stack
- operandStack.push(a - b);
+ operandStack.push((short)(a - b));
// Return the updated program counter (next instruction)
return currentPC + 1;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SXorCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SXorCommand.java
new file mode 100644
index 0000000..dd0a8be
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/control/short16/SXorCommand.java
@@ -0,0 +1,56 @@
+package org.jcnc.snow.vm.commands.type.control.short16;
+
+import org.jcnc.snow.vm.interfaces.Command;
+import org.jcnc.snow.vm.module.CallStack;
+import org.jcnc.snow.vm.module.LocalVariableStore;
+import org.jcnc.snow.vm.module.OperandStack;
+
+/**
+ * The {@code SXorCommand} class implements the {@link Command} interface and represents the short16 bitwise XOR (`^`) operation command.
+ * This class performs a short16 bitwise XOR operation in the virtual machine by popping the top two values from the stack,
+ * computing their XOR, and then pushing the result back onto the stack. It is a basic operation command within the virtual machine.
+ *
+ * Operation details:
+ *
+ * - Pops two operands from the virtual machine stack.
+ * - Performs the short16 bitwise XOR (`^`) operation.
+ * - Pushes the result back onto the virtual machine stack.
+ *
+ */
+public class SXorCommand implements Command {
+ /**
+ * Default constructor for creating an instance of {@code SXorCommand}.
+ * This constructor is empty as no specific initialization is required.
+ */
+ public SXorCommand() {
+ // Empty constructor
+ }
+
+ /**
+ * Executes the virtual machine instruction's operation.
+ *
+ * @param parts The array of instruction parameters, which usually includes the operator and related arguments.
+ * @param currentPC The current program counter-value, indicating the address of the instruction being executed.
+ * @param operandStack The virtual machine's operand stack manager, responsible for performing stack operations.
+ * @param localVariableStore The local variable store, typically used to manage method-local variables.
+ * @param callStack The virtual machine's call stack, which keeps track of method invocations.
+ * @return The updated program counter-value, typically {@code currentPC + 1}, unless a control flow instruction is executed.
+ * @throws IllegalStateException if there are not enough operands on the stack to perform the operation.
+ */
+ @Override
+ public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) {
+ // Ensure the stack has at least two operands
+ if (operandStack.size() < 2) {
+ throw new IllegalStateException("Not enough operands on the stack for SXOR operation.");
+ }
+
+ // Pop the top two operands from the stack
+ final short b = (short) operandStack.pop();
+ final short a = (short) operandStack.pop();
+
+ // Perform the short16 bitwise XOR operation and push the result back onto the stack
+ operandStack.push((short)(a ^ b));
+
+ return currentPC + 1;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/B2ICommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/B2ICommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/B2ICommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/B2ICommand.java
index 7abd324..c5c18a6 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/B2ICommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/B2ICommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2FCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2FCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2FCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2FCommand.java
index 3ed687f..7f4bcc0 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2FCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2FCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2ICommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2ICommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2ICommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2ICommand.java
index b0c706c..903f6dc 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2ICommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2ICommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2LCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2LCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2LCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2LCommand.java
index eb38865..78d558a 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/D2LCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/D2LCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2DCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2DCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2DCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2DCommand.java
index e997502..7f4dba7 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2DCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2DCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2ICommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2ICommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2ICommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2ICommand.java
index 26cf949..24f9192 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2ICommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2ICommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2LCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2LCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2LCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2LCommand.java
index 55abcbc..b4bcb6b 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/F2LCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/F2LCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2BCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2BCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2BCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2BCommand.java
index 84e2e92..76ef29c 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2BCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2BCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2DCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2DCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2DCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2DCommand.java
index 3653a36..0147f5b 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2DCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2DCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2FCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2FCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2FCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2FCommand.java
index f21e379..22182dc 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2FCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2FCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2LCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2LCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2LCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2LCommand.java
index 9198cfa..a9d1aae 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2LCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2LCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2SCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2SCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2SCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2SCommand.java
index f11f119..ca5987a 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/I2SCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/I2SCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2DCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2DCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2DCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2DCommand.java
index 7c551db..06426ae 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2DCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2DCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2FCommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2FCommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2FCommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2FCommand.java
index f2cbfc2..5cf6a67 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2FCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2FCommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2ICommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2ICommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2ICommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2ICommand.java
index ee9f494..f4f4b41 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/L2ICommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/L2ICommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/S2ICommand.java b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/S2ICommand.java
similarity index 97%
rename from src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/S2ICommand.java
rename to src/main/java/org/jcnc/snow/vm/commands/type/conversion/S2ICommand.java
index 375f0ea..fa3ee74 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/conversion/S2ICommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/type/conversion/S2ICommand.java
@@ -1,4 +1,4 @@
-package org.jcnc.snow.vm.commands.arithmetic.conversion;
+package org.jcnc.snow.vm.commands.type.conversion;
import org.jcnc.snow.vm.interfaces.Command;
import org.jcnc.snow.vm.module.CallStack;
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 b3a6680..c53f511 100644
--- a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java
+++ b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java
@@ -1,45 +1,44 @@
package org.jcnc.snow.vm.engine;
-import org.jcnc.snow.vm.commands.arithmetic.byte8.*;
-import org.jcnc.snow.vm.commands.arithmetic.conversion.*;
-import org.jcnc.snow.vm.commands.arithmetic.double64.*;
-import org.jcnc.snow.vm.commands.arithmetic.float32.*;
-import org.jcnc.snow.vm.commands.arithmetic.int32.*;
-import org.jcnc.snow.vm.commands.arithmetic.long64.*;
-import org.jcnc.snow.vm.commands.arithmetic.short16.*;
-import org.jcnc.snow.vm.commands.bitwise.int32.IAndCommand;
-import org.jcnc.snow.vm.commands.bitwise.int32.IOrCommand;
-import org.jcnc.snow.vm.commands.bitwise.int32.IXorCommand;
-import org.jcnc.snow.vm.commands.bitwise.long64.LAndCommand;
-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.function.CallCommand;
-import org.jcnc.snow.vm.commands.function.RetCommand;
-import org.jcnc.snow.vm.commands.memory.all.MovCommand;
-import org.jcnc.snow.vm.commands.memory.byte8.BLoadCommand;
-import org.jcnc.snow.vm.commands.memory.byte8.BStoreCommand;
-import org.jcnc.snow.vm.commands.memory.double64.DLoadCommand;
-import org.jcnc.snow.vm.commands.memory.double64.DStoreCommand;
-import org.jcnc.snow.vm.commands.memory.float32.FLoadCommand;
-import org.jcnc.snow.vm.commands.memory.float32.FStoreCommand;
-import org.jcnc.snow.vm.commands.memory.int32.ILoadCommand;
-import org.jcnc.snow.vm.commands.memory.int32.IStoreCommand;
-import org.jcnc.snow.vm.commands.memory.long64.LLoadCommand;
-import org.jcnc.snow.vm.commands.memory.long64.LStoreCommand;
-import org.jcnc.snow.vm.commands.memory.short16.SLoadCommand;
-import org.jcnc.snow.vm.commands.memory.short16.SStoreCommand;
-import org.jcnc.snow.vm.commands.stack.all.DupCommand;
-import org.jcnc.snow.vm.commands.stack.all.PopCommand;
-import org.jcnc.snow.vm.commands.stack.all.SwapCommand;
-import org.jcnc.snow.vm.commands.stack.byte8.BPushCommand;
-import org.jcnc.snow.vm.commands.stack.double64.DPushCommand;
-import org.jcnc.snow.vm.commands.stack.float32.FPushCommand;
-import org.jcnc.snow.vm.commands.stack.int32.IPushCommand;
-import org.jcnc.snow.vm.commands.stack.long64.LPushCommand;
-import org.jcnc.snow.vm.commands.stack.short16.SPushCommand;
-import org.jcnc.snow.vm.commands.vm.HaltCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.*;
+import org.jcnc.snow.vm.commands.type.control.double64.*;
+import org.jcnc.snow.vm.commands.type.control.float32.*;
+import org.jcnc.snow.vm.commands.type.control.int32.*;
+import org.jcnc.snow.vm.commands.type.control.long64.*;
+import org.jcnc.snow.vm.commands.type.control.short16.*;
+import org.jcnc.snow.vm.commands.type.control.int32.IAndCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IOrCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IXorCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LAndCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LOrCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LXorCommand;
+import org.jcnc.snow.vm.commands.flow.control.JumpCommand;
+import org.jcnc.snow.vm.commands.flow.control.CallCommand;
+import org.jcnc.snow.vm.commands.flow.control.RetCommand;
+import org.jcnc.snow.vm.commands.register.control.MovCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.BLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.BStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.double64.DLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.double64.DStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.float32.FLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.float32.FStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.ILoadCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SStoreCommand;
+import org.jcnc.snow.vm.commands.stack.control.DupCommand;
+import org.jcnc.snow.vm.commands.stack.control.PopCommand;
+import org.jcnc.snow.vm.commands.stack.control.SwapCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.BPushCommand;
+import org.jcnc.snow.vm.commands.type.control.double64.DPushCommand;
+import org.jcnc.snow.vm.commands.type.control.float32.FPushCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IPushCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LPushCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SPushCommand;
+import org.jcnc.snow.vm.commands.type.conversion.*;
+import org.jcnc.snow.vm.commands.system.control.HaltCommand;
import org.jcnc.snow.vm.module.LocalVariableStore;
/**
@@ -47,88 +46,103 @@ import org.jcnc.snow.vm.module.LocalVariableStore;
* Each opcode represents a specific operation executed by the virtual machine.
*/
public class VMOpCode {
- // 1 Arithmetic Operations (1–80)
- // 1.1 int32 (1-10)
+
+ // region Type Control (0x0000-0x00BF)
+ // 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:
*
- * - 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).
- * - Performs the addition operation on these two int32s.
+ * - 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).
+ * - Performs the addition operation on these two byte8 values.
* - Pushes the result of the addition back onto the operand stack for later instructions to use.
*
*
* 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 = 1;
+ 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:
*
- * - 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).
+ * - 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).
* - Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
* - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
*
*
* 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 = 2;
+ 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:
*
- * - 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).
- * - Performs the multiplication operation on these two int32s (i.e.,
firstOperand * secondOperand).
+ * - 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).
+ * - Performs the multiplication operation on these two byte8 values (i.e.,
firstOperand * secondOperand).
* - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
*
*
* 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 = 3;
+ 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:
*
- * - 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).
+ * - 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).
* - Performs the division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
* - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
* - Pushes the result of the division back onto the operand stack for later instructions to use.
*
*
* 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 = 4;
+ 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:
*
- * - 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).
+ * - 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).
* - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
* - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
* - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
*
*
* 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 = 5;
+ 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:
+ *
+ * - Pops the top byte8 value from the operand stack.
+ * - Performs the negation of the popped value (i.e.,
-value).
+ * - Pushes the negated result back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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,158 +154,255 @@ public class VMOpCode {
* - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
*
*
- * 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 = 6;
-
+ public static final int B_INC = 0x0006;
/**
- * 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.
+ * I_AND Opcode: Represents the byte8 bitwise AND operation in the virtual machine.
+ * This opcode is implemented by the {@link IAndCommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Pops the top int32 value from the operand stack.
- * - Performs the negation of the popped value (i.e.,
-value).
- * - Pushes the negated result back onto the operand stack for later instructions to use.
+ * - Pops the top two byte8 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - Performs the byte8 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.
+ *
+ *
+ * - Pushes the result of the byte8 bitwise AND operation back onto the operand stack for further processing.
*
*
- * 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 essential for low-level bit manipulation tasks.
*/
- public static final int I_NEG = 7;
- // 1.2 long64 (11-20)
+ public static final int B_AND = 0x0007;
/**
- * 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.
+ * I_OR Opcode: Represents the byte8 bitwise OR operation in the virtual machine.
+ * This opcode is implemented by the {@link IOrCommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - 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).
- * - Performs the addition operation on these two long64s.
- * - Pushes the result of the addition back onto the operand stack for later instructions to use.
+ * - Pops the top two byte8 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - Performs the byte8 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.
+ *
+ *
+ * - Pushes the result of the byte8 bitwise OR operation back onto the operand stack for further processing.
*
*
- * This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
- * primarily used to handle basic long64 addition tasks.
+ * This opcode is essential for low-level bit manipulation tasks.
*/
- public static final int L_ADD = 11;
-
+ public static final int B_OR = 0x0008;
/**
- * 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.
+ * I_XOR Opcode: Represents the byte8 bitwise XOR operation in the virtual machine.
+ * This opcode is implemented by the {@link IXorCommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - 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).
- * - Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
- * - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
+ * - Pops the top two byte8 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - Performs the byte8 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.
+ *
+ *
+ * - Pushes the result of the byte8 bitwise XOR operation back onto the operand stack for further processing.
*
*
- * This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
- * primarily used to handle basic long64 subtraction tasks.
+ * This opcode is essential for low-level bit manipulation tasks.
*/
- public static final int L_SUB = 12;
-
+ public static final int B_XOR = 0x0009;
/**
- * 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.
+ * 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:
*
- * - 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).
- * - Performs the multiplication operation on these two long64s (i.e.,
firstOperand * secondOperand).
- * - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
+ * - Parses the byte8 value from the instruction parameters.
+ * - Pushes the parsed byte8 value onto the operand stack.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
- * This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
- * primarily used to handle basic long64 multiplication tasks.
+ * 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_MUL = 13;
-
+ public static final int B_PUSH = 0x000A;
/**
- * 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.
+ * 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:
*
- * - 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).
- * - Performs the division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
- * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
- * - Pushes the result of the division back onto the operand stack for later instructions to use.
+ * - Retrieves the index for the local variable from the instruction parameters.
+ * - Retrieves the corresponding value from the local variable store of the current method frame.
+ * - Pushes the retrieved value onto the operand stack for subsequent operations.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
- * This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
- * primarily used to handle basic long64 division tasks.
+ * 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 L_DIV = 14;
-
+ public static final int B_LOAD = 0x000B;
/**
- * 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.
+ * 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:
*
- * - 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).
- * - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
- * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
- * - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
+ * - Retrieves the index for the local variable from the instruction parameters.
+ * - Pops a byte8 value from the operand stack.
+ * - Stores the value into the local variable store at the specified index of the current method frame.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
- * This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
- * primarily used to handle basic long64 modulus (remainder) tasks.
+ * 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 L_MOD = 15;
-
+ public static final int B_STORE = 0x000C;
/**
- * 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.
+ * I_CE Opcode: Represents a conditional jump based on byte8 equality.
+ * This opcode is implemented by the {@link ICECommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Retrieves the index of the local variable and the increment value from the instruction parameters.
- * - Gets the current value of the local variable at the specified index from the local variable store.
- * - Increments the local variable's value by the specified increment (i.e.,
- *
localVariables[index] += increment).
- * - Updates the local variable store with the new incremented value.
- * - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two byte8 values from the operand stack.
+ * - Compares the two byte8 for equality.
+ * - If the byte8 are equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the byte8 are not equal, increments the program counter to proceed with the next sequential instruction.
*
*
- * This opcode is particularly useful for optimizing scenarios where a local `long64` variable, such as a counter or loop index, is frequently incremented.
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on byte8 comparison.
+ * - Implementing control flow structures such as if-statements and loops.
+ *
*/
- public static final int L_INC = 16;
-
-
+ public static final int B_CE = 0x000D;
/**
- * 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.
+ * I_CNE Opcode: Represents a conditional jump based on byte8 inequality.
+ * This opcode is implemented by the {@link ICNECommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Pops the top long64 value from the operand stack.
- * - Performs the negation of the popped value (i.e.,
-value).
- * - Pushes the negated result back onto the operand stack for later instructions to use.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two byte8 values from the operand stack.
+ * - Compares the two byte8 for inequality.
+ * - If the byte8 are not equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the byte8 are equal, increments the program counter to proceed with the next sequential instruction.
*
*
- * This opcode is typically used to negate a long64 value, making it a fundamental operation for arithmetic logic within the virtual machine.
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on byte8 comparison.
+ * - Implementing control flow structures such as conditional loops and if-else statements.
+ *
*/
- public static final int L_NEG = 17;
-
- // 1.3 short16 (21-30)
+ public static final int B_CNE = 0x000E;
/**
- * 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.
+ * I_CG Opcode: Represents a conditional jump based on byte8 comparison (greater than).
+ * This opcode is implemented by the {@link ICGCommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - 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).
- * - Performs the addition operation on these two short16 values.
- * - Pushes the result of the addition back onto the operand stack for later instructions to use.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two byte8 values from the operand stack.
+ * - Compares the first byte8 with the second to determine if it is greater.
+ * - If the first byte8 is greater than the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first byte8 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
*
*
- * This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
- * primarily used to handle basic short16 addition tasks.
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on byte8 comparison.
+ * - Implementing control flow structures such as greater-than conditions in loops and conditional statements.
+ *
*/
- public static final int S_ADD = 21;
+ public static final int B_CG = 0x000F;
+ /**
+ * I_CGE Opcode: Represents a conditional jump based on byte8 comparison (greater than or equal to).
+ * This opcode is implemented by the {@link ICGECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two byte8 values from the operand stack.
+ * - Compares the first byte8 with the second to determine if it is greater than or equal to the second byte8.
+ * - If the first byte8 is greater than or equal to the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first byte8 is less than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on byte8 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and range checks.
+ *
+ */
+ public static final int B_CGE = 0x0010;
+ /**
+ * I_CL Opcode: Represents a conditional jump based on byte8 comparison (less than).
+ * This opcode is implemented by the {@link ICLCommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two byte8 values from the operand stack.
+ * - Compares the first byte8 with the second to determine if it is less than the second byte8.
+ * - If the first byte8 is less than the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first byte8 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on byte8 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and range validations.
+ *
+ */
+ public static final int B_CL = 0x0011;
+ /**
+ * B_CLE Opcode: Represents a conditional jump based on byte8 comparison (less than or equal).
+ * This opcode is implemented by the {@link ICLECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two byte8 values from the operand stack.
+ * - Compares the first byte8 with the second to determine if it is less than or equal to the second byte8.
+ * - If the first byte8 is less than or equal to the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first byte8 is greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on byte8 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and boundary checks.
+ *
+ */
+ public static final int B_CLE = 0x0012;
+ // endregion
+ // 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.
@@ -306,8 +417,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 = 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.
@@ -322,8 +432,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 = 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.
@@ -339,8 +448,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 = 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.
@@ -356,8 +464,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 = 25;
-
+ 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:
+ *
+ * - Pops the top short16 value from the operand stack.
+ * - Performs the negation of the popped value (i.e.,
-value).
+ * - Pushes the negated result back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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.
@@ -375,918 +496,64 @@ 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 = 0x0026;
/**
- * 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:
- *
- * - Pops the top short16 value from the operand stack.
- * - Performs the negation of the popped value (i.e.,
-value).
- * - Pushes the negated result back onto the operand stack for later instructions to use.
- *
- *
- * 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;
-
- // 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:
- *
- * - 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).
- * - Performs the addition operation on these two byte8 values.
- * - Pushes the result of the addition back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
- * - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the multiplication operation on these two byte8 values (i.e.,
firstOperand * secondOperand).
- * - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
- * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
- * - Pushes the result of the division back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
- * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
- * - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - Retrieves the index of the local variable and the increment value from the instruction parameters.
- * - Gets the current value of the local variable at the specified index from the local variable store.
- * - Increments the local variable's value by the specified increment (i.e.,
- *
localVariables[index] += increment).
- * - Updates the local variable store with the new incremented value.
- * - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
- *
- *
- * 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:
- *
- * - Pops the top byte8 value from the operand stack.
- * - Performs the negation of the popped value (i.e.,
-value).
- * - Pushes the negated result back onto the operand stack for later instructions to use.
- *
- *
- * 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;
-
- // 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:
- *
- * - 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).
- * - Performs the double64 precision floating-point addition operation on these two operands.
- * - Pushes the result of the addition back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the double64 precision floating-point subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
- * - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the double64 precision floating-point multiplication operation on these two operands (i.e.,
firstOperand * secondOperand).
- * - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the double64 precision floating-point division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
- * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
- * - Pushes the result of the division back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
- * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
- * - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - Retrieves the index of the local variable and the increment value from the instruction parameters.
- * - Gets the current value of the local variable at the specified index from the local variable store.
- * - Increments the local variable's value by the specified increment (i.e.,
- *
localVariables[index] += increment).
- * - Updates the local variable store with the new incremented value.
- * - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
- *
- *
- * 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:
- *
- * - Pops the top double64 value from the operand stack.
- * - Performs the negation of the popped value (i.e.,
-value).
- * - Pushes the negated result back onto the operand stack for later instructions to use.
- *
- *
- * 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;
-
- // 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:
- *
- * - 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).
- * - Performs the float32 addition operation on these two operands.
- * - Pushes the result of the addition back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the float32 subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
- * - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the float32 multiplication operation on these two operands (i.e.,
firstOperand * secondOperand).
- * - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the float32 division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
- * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
- * - Pushes the result of the division back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - 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).
- * - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
- * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
- * - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
- *
- *
- * 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:
- *
- * - Retrieves the index of the local variable and the increment value from the instruction parameters.
- * - Gets the current value of the local variable at the specified index from the local variable store.
- * - Increments the local variable's value by the specified increment (i.e.,
- *
localVariables[index] += increment).
- * - Updates the local variable store with the new incremented value.
- * - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
- *
- *
- * 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:
- *
- * - Pops the top float32 value from the operand stack.
- * - Performs the negation of the popped value (i.e.,
-value).
- * - Pushes the negated result back onto the operand stack for later instructions to use.
- *
- *
- * 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;
-
- /**
- * 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:
- *
- * - Pop the top int32 value from the operand stack.
- * - Convert the int32 value to a long64 value.
- * - Push the converted long64 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top int32 value from the operand stack.
- * - Convert the int32 value to a short16 value (this may involve truncation).
- * - Push the converted short16 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top int32 value from the operand stack.
- * - Convert the int32 value to a byte8 value (this may involve truncation).
- * - Push the converted byte8 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top int32 value from the operand stack.
- * - Convert the int32 value to a double64 value.
- * - Push the converted double64 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top int32 value from the operand stack.
- * - Convert the int32 value to a float32 value.
- * - Push the converted float32 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top long64 value from the operand stack.
- * - Convert the long64 value to an int32 value (this may involve truncation).
- * - Push the converted int32 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top long64 value from the operand stack.
- * - Convert the long64 value to a double64 value.
- * - Push the converted double64 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top long64 value from the operand stack.
- * - Convert the long64 value to a float32 value.
- * - Push the converted float32 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top float32 value from the operand stack.
- * - Convert the float32 value to an int32 value (this may involve truncation).
- * - Push the converted int32 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top float32 value from the operand stack.
- * - Convert the float32 value to a long64 value.
- * - Push the converted long64 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top float32 value from the operand stack.
- * - Convert the float32 value to a double64 value.
- * - Push the converted double64 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top double64 value from the operand stack.
- * - Convert the double64 value to an int32 value (this may involve truncation).
- * - Push the converted int32 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top double64 value from the operand stack.
- * - Convert the double64 value to a long64 value (this may involve truncation).
- * - Push the converted long64 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top double64 value from the operand stack.
- * - Convert the double64 value to a float32 value.
- * - Push the converted float32 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top short16 value from the operand stack.
- * - Convert the short16 value to an int32 value.
- * - Push the converted int32 value back onto the operand stack for subsequent operations.
- *
- *
- * 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:
- *
- * - Pop the top byte8 value from the operand stack.
- * - Convert the byte8 value to an int32 value.
- * - Push the converted int32 value back onto the operand stack for subsequent operations.
- *
- *
- * 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;
-
-
-
- // 2. Bitwise Operations (81–90)
- // 2.1 int32 (81-85)
- /**
- * I_AND Opcode: Represents the int32 bitwise AND operation in the virtual machine.
+ * I_AND Opcode: Represents the short16 bitwise AND operation in the virtual machine.
* This opcode is implemented by the {@link IAndCommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
- * - Performs the int32 bitwise AND operation on the two popped operands. The operation compares corresponding bits of both operands:
+ *
- Pops the top two short16 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - Performs the short16 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.
*
*
- * - Pushes the result of the int32 bitwise AND operation back onto the operand stack for further processing.
+ * - Pushes the result of the short16 bitwise AND operation back onto the operand stack for further processing.
*
*
* This opcode is essential for low-level bit manipulation tasks.
*/
- public static final int I_AND = 81;
+ public static final int S_AND = 0x0027;
/**
- * I_OR Opcode: Represents the int32 bitwise OR operation in the virtual machine.
+ * I_OR Opcode: Represents the short16 bitwise OR operation in the virtual machine.
* This opcode is implemented by the {@link IOrCommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
- * - Performs the int32 bitwise OR operation on the two popped operands. The operation compares corresponding bits of both operands:
+ *
- Pops the top two short16 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - Performs the short16 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.
*
*
- * - Pushes the result of the int32 bitwise OR operation back onto the operand stack for further processing.
+ * - Pushes the result of the short16 bitwise OR operation back onto the operand stack for further processing.
*
*
* This opcode is essential for low-level bit manipulation tasks.
*/
- public static final int I_OR = 82;
-
+ public static final int S_OR = 0x0028;
/**
- * I_XOR Opcode: Represents the int32 bitwise XOR operation in the virtual machine.
+ * I_XOR Opcode: Represents the short16 bitwise XOR operation in the virtual machine.
* This opcode is implemented by the {@link IXorCommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
- * - Performs the int32 bitwise XOR (exclusive OR) operation on the two operands:
+ *
- Pops the top two short16 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - Performs the short16 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.
*
*
- * - Pushes the result of the int32 bitwise XOR operation back onto the operand stack for further processing.
+ * - Pushes the result of the short16 bitwise XOR operation back onto the operand stack for further processing.
*
*
* This opcode is essential for low-level bit manipulation tasks.
*/
- public static final int I_XOR = 83;
-
- // 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:
- *
- * - Pops the top two long64 values from the operand stack. These values are treated as 32-bit binary representations.
- * - 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.
- *
- *
- * - Pushes the result of the long64 bitwise AND operation back onto the operand stack for further processing.
- *
- *
- * 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:
- *
- * - Pops the top two long64 values from the operand stack. These values are treated as 32-bit binary representations.
- * - 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.
- *
- *
- * - Pushes the result of the long64 bitwise OR operation back onto the operand stack for further processing.
- *
- *
- * 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:
- *
- * - Pops the top two long64 values from the operand stack. These values are treated as 32-bit binary representations.
- * - 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.
- *
- *
- * - Pushes the result of the long64 bitwise XOR operation back onto the operand stack for further processing.
- *
- *
- * This opcode is essential for low-level bit manipulation tasks.
- */
- public static final int L_XOR = 88;
-
-
- // 3. Control Flow Operations (91–110)
- /**
- * 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:
- *
- * - Parses the target instruction address from the instruction parameters.
- * - Validates the target address to ensure it is a non-negative int32.
- * - 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.
- * - If the target address is invalid (less than 0), logs an error message and halts execution by returning an invalid value (typically -1).
- *
- *
- * This opcode is commonly used for:
- *
- * - Control flow management in virtual machine execution.
- *
- */
- public static final int JUMP = 91;
- /**
- * 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:
- *
- * - Parses the target instruction address from the instruction parameters.
- * - Pops two int32 values from the operand stack.
- * - Compares the two int32s for equality.
- * - If the int32s are equal, updates the program counter (PC) to the specified target address,
- * effectively jumping to the target instruction.
- * - If the int32s are not equal, increments the program counter to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Parses the target instruction address from the instruction parameters.
- * - Pops two int32 values from the operand stack.
- * - Compares the two int32s for inequality.
- * - If the int32s are not equal, updates the program counter (PC) to the specified target address,
- * effectively jumping to the target instruction.
- * - If the int32s are equal, increments the program counter to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Parses the target instruction address from the instruction parameters.
- * - Pops two int32 values from the operand stack.
- * - Compares the first int32 with the second to determine if it is greater.
- * - 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.
- * - If the first int32 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Parses the target instruction address from the instruction parameters.
- * - Pops two int32 values from the operand stack.
- * - Compares the first int32 with the second to determine if it is greater than or equal to the second int32.
- * - 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.
- * - If the first int32 is less than the second, increments the program counter to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Parses the target instruction address from the instruction parameters.
- * - Pops two int32 values from the operand stack.
- * - Compares the first int32 with the second to determine if it is less than the second int32.
- * - 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.
- * - If the first int32 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Parses the target instruction address from the instruction parameters.
- * - Pops two int32 values from the operand stack.
- * - Compares the first int32 with the second to determine if it is less than or equal to the second int32.
- * - 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.
- * - If the first int32 is greater than the second, increments the program counter to proceed with the next sequential instruction.
- *
- *
- * 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;
-
- // 4. Stack Operations (111–150)
- // 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:
- *
- * - Parses the int32 value from the instruction parameters.
- * - Pushes the parsed int32 value onto the operand stack.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Parses the long64 value from the instruction parameters.
- * - Pushes the parsed long64 value onto the operand stack.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
- *
- *
- * 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;
+ public static final int S_XOR = 0x0029;
/**
* 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.
@@ -1305,127 +572,380 @@ 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:
*
- * - Parses the byte8 value from the instruction parameters.
- * - Pushes the parsed byte8 value onto the operand stack.
+ * - Retrieves the index for the local variable from the instruction parameters.
+ * - Retrieves the corresponding value from the local variable store of the current method frame.
+ * - Pushes the retrieved value onto the operand stack for subsequent operations.
* - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
* 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 B_PUSH = 114;
+ public static final int S_LOAD = 0x002B;
/**
- * 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.
+ * 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:
*
- * - Parses the double64 value from the instruction parameters.
- * - Pushes the parsed double64 value onto the operand stack.
+ * - Retrieves the index for the local variable from the instruction parameters.
+ * - Pops a short16 value from the operand stack.
+ * - Stores the value into the local variable store at the specified index of the current method frame.
* - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
* 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.
+ * - 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 D_PUSH = 115;
+ public static final int S_STORE = 0x002C;
/**
- * 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.
+ * I_CE Opcode: Represents a conditional jump based on short16 equality.
+ * This opcode is implemented by the {@link ICECommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Parses the float32 value from the instruction parameters.
- * - Pushes the parsed float32 value onto the operand stack.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two short16 values from the operand stack.
+ * - Compares the two short16 for equality.
+ * - If the short16 are equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the short16 are not equal, increments the program counter to proceed with the next sequential instruction.
*
*
* 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.
+ * - Conditional branching in virtual machine execution based on short16 comparison.
+ * - Implementing control flow structures such as if-statements and loops.
*
*/
- public static final int F_PUSH = 116;
+ public static final int S_CE = 0x002D;
/**
- * 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.
+ * I_CNE Opcode: Represents a conditional jump based on short16 inequality.
+ * This opcode is implemented by the {@link ICNECommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Removes (pops) the top element from the operand stack.
- * - Discards the popped value, as it is not stored or used further.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two short16 values from the operand stack.
+ * - Compares the two short16 for inequality.
+ * - If the short16 are not equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the short16 are equal, increments the program counter to proceed with the next sequential instruction.
*
*
* 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.
+ * - Conditional branching in virtual machine execution based on short16 comparison.
+ * - Implementing control flow structures such as conditional loops and if-else statements.
*
*/
- // 4.2 POP (121-125)
- public static final int POP = 121;
+ public static final int S_CNE = 0x002E;
/**
- * 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.
+ * I_CG Opcode: Represents a conditional jump based on short16 comparison (greater than).
+ * This opcode is implemented by the {@link ICGCommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Retrieves the top element from the operand stack.
- * - Duplicates the top value and pushes it back onto the stack.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two short16 values from the operand stack.
+ * - Compares the first short16 with the second to determine if it is greater.
+ * - If the first short16 is greater than the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first short16 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
*
*
* 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.
+ * - Conditional branching in virtual machine execution based on short16 comparison.
+ * - Implementing control flow structures such as greater-than conditions in loops and conditional statements.
*
*/
- // 4.3 DUP (126-130)
- public static final int DUP = 126;
+ public static final int S_CG = 0x002F;
/**
- * 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.
+ * I_CGE Opcode: Represents a conditional jump based on short16 comparison (greater than or equal to).
+ * This opcode is implemented by the {@link ICGECommand} class, which defines its specific execution logic.
*
* Execution Steps:
*
- * - Ensures that there are at least two elements on the operand stack.
- * - Pops the two topmost values from the stack.
- * - Pushes the two values back onto the stack in reversed order.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two short16 values from the operand stack.
+ * - Compares the first short16 with the second to determine if it is greater than or equal to the second short16.
+ * - If the first short16 is greater than or equal to the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first short16 is less than the second, increments the program counter to proceed with the next sequential instruction.
*
*
* 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.
+ * - Conditional branching in virtual machine execution based on short16 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and range checks.
*
*/
- // 4.4 SWAP (131-135)
- public static final int SWAP = 131;
+ public static final int S_CGE = 0x0030;
+ /**
+ * I_CL Opcode: Represents a conditional jump based on short16 comparison (less than).
+ * This opcode is implemented by the {@link ICLCommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two short16 values from the operand stack.
+ * - Compares the first short16 with the second to determine if it is less than the second short16.
+ * - If the first short16 is less than the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first short16 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on short16 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and range validations.
+ *
+ */
+ public static final int S_CL = 0x0031;
+ /**
+ * S_CLE Opcode: Represents a conditional jump based on short16 comparison (less than or equal).
+ * This opcode is implemented by the {@link ICLECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two short16 values from the operand stack.
+ * - Compares the first short16 with the second to determine if it is less than or equal to the second short16.
+ * - If the first short16 is less than or equal to the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first short16 is greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on short16 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and boundary checks.
+ *
+ */
+ public static final int S_CLE = 0x0032;
+ // endregion
- // 5. Memory Operations (151–)
+ // 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:
+ *
+ * - 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).
+ * - Performs the addition operation on these two int32s.
+ * - Pushes the result of the addition back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
+ * - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the multiplication operation on these two int32s (i.e.,
firstOperand * secondOperand).
+ * - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
+ * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
+ * - Pushes the result of the division back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
+ * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
+ * - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top int32 value from the operand stack.
+ * - Performs the negation of the popped value (i.e.,
-value).
+ * - Pushes the negated result back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - Retrieves the index of the local variable and the increment value from the instruction parameters.
+ * - Gets the current value of the local variable at the specified index from the local variable store.
+ * - Increments the local variable's value by the specified increment (i.e.,
+ *
localVariables[index] += increment).
+ * - Updates the local variable store with the new incremented value.
+ * - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - 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.
+ *
+ *
+ * - Pushes the result of the int32 bitwise AND operation back onto the operand stack for further processing.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - 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.
+ *
+ *
+ * - Pushes the result of the int32 bitwise OR operation back onto the operand stack for further processing.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top two int32 values from the operand stack. These values are treated as 32-bit binary representations.
+ * - 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.
+ *
+ *
+ * - Pushes the result of the int32 bitwise XOR operation back onto the operand stack for further processing.
+ *
+ *
+ * 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:
+ *
+ * - Parses the int32 value from the instruction parameters.
+ * - Pushes the parsed int32 value onto the operand stack.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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 = 0x004A;
+ /**
+ * 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:
+ *
+ * - Retrieves the index for the local variable from the instruction parameters.
+ * - Retrieves the corresponding value from the local variable store of the current method frame.
+ * - Pushes the retrieved value onto the operand stack for subsequent operations.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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 = 0x004B;
/**
* I_STORE Opcode: Represents a store operation that saves an int32 value from the operand stack into the local variable store.
*
@@ -1446,138 +966,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:
*
- * - Retrieves the index for the local variable from the instruction parameters.
- * - Pops a long64 value from the operand stack.
- * - Stores the value into the local variable store at the specified index of the current method frame.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two int32 values from the operand stack.
+ * - Compares the two int32s for equality.
+ * - If the int32s are equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the int32s are not equal, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two int32 values from the operand stack.
+ * - Compares the two int32s for inequality.
+ * - If the int32s are not equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the int32s are equal, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two int32 values from the operand stack.
+ * - Compares the first int32 with the second to determine if it is greater.
+ * - 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.
+ * - If the first int32 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two int32 values from the operand stack.
+ * - Compares the first int32 with the second to determine if it is greater than or equal to the second int32.
+ * - 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.
+ * - If the first int32 is less than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two int32 values from the operand stack.
+ * - Compares the first int32 with the second to determine if it is less than the second int32.
+ * - 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.
+ * - If the first int32 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two int32 values from the operand stack.
+ * - Compares the first int32 with the second to determine if it is less than or equal to the second int32.
+ * - 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.
+ * - If the first int32 is greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the addition operation on these two long64.
+ * - Pushes the result of the addition back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
+ * - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the multiplication operation on these two long64 (i.e.,
firstOperand * secondOperand).
+ * - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
+ * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
+ * - Pushes the result of the division back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
+ * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
+ * - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top long64 value from the operand stack.
+ * - Performs the negation of the popped value (i.e.,
-value).
+ * - Pushes the negated result back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - Retrieves the index of the local variable and the increment value from the instruction parameters.
+ * - Gets the current value of the local variable at the specified index from the local variable store.
+ * - Increments the local variable's value by the specified increment (i.e.,
+ *
localVariables[index] += increment).
+ * - Updates the local variable store with the new incremented value.
+ * - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top two long64 values from the operand stack. These values are treated as 64-bit binary representations.
+ * - 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.
+ *
+ *
+ * - Pushes the result of the long64 bitwise AND operation back onto the operand stack for further processing.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top two long64 values from the operand stack. These values are treated as 64-bit binary representations.
+ * - 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.
+ *
+ *
+ * - Pushes the result of the long64 bitwise OR operation back onto the operand stack for further processing.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top two long64 values from the operand stack. These values are treated as 64-bit binary representations.
+ * - 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.
+ *
+ *
+ * - Pushes the result of the long64 bitwise XOR operation back onto the operand stack for further processing.
+ *
+ *
+ * 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:
+ *
+ * - Parses the long64 value from the instruction parameters.
+ * - Pushes the parsed long64 value onto the operand stack.
* - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
* 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:
- *
- * - Retrieves the index for the local variable from the instruction parameters.
- * - Pops a short16 value from the operand stack.
- * - Stores the value into the local variable store at the specified index of the current method frame.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Retrieves the index for the local variable from the instruction parameters.
- * - Pops a byte8 value from the operand stack.
- * - Stores the value into the local variable store at the specified index of the current method frame.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Retrieves the index for the local variable from the instruction parameters.
- * - Pops a double64 value from the operand stack.
- * - Stores the value into the local variable store at the specified index of the current method frame.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Retrieves the index for the local variable from the instruction parameters.
- * - Pops a float32 value from the operand stack.
- * - Stores the value into the local variable store at the specified index of the current method frame.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
- *
- *
- * 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:
- *
- * - Retrieves the index for the local variable from the instruction parameters.
- * - Retrieves the corresponding value from the local variable store of the current method frame.
- * - Pushes the retrieved value onto the operand stack for subsequent operations.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
- *
- *
- * 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.
@@ -1597,67 +1299,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:
*
* - Retrieves the index for the local variable from the instruction parameters.
- * - Retrieves the corresponding value from the local variable store of the current method frame.
- * - Pushes the retrieved value onto the operand stack for subsequent operations.
+ * - Pops a long64 value from the operand stack.
+ * - Stores the value into the local variable store at the specified index of the current method frame.
* - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
* 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:
*
- * - Retrieves the index for the local variable from the instruction parameters.
- * - Retrieves the corresponding value from the local variable store of the current method frame.
- * - Pushes the retrieved value onto the operand stack for subsequent operations.
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two long64 values from the operand stack.
+ * - Compares the two long64 for equality.
+ * - If the long64 are equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the long64 are not equal, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two long64 values from the operand stack.
+ * - Compares the two long64 for inequality.
+ * - If the long64 are not equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the long64 are equal, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two long64 values from the operand stack.
+ * - Compares the first long64 with the second to determine if it is greater.
+ * - 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.
+ * - If the first long64 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two long64 values from the operand stack.
+ * - Compares the first long64 with the second to determine if it is greater than or equal to the second long64.
+ * - 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.
+ * - If the first long64 is less than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two long64 values from the operand stack.
+ * - Compares the first long64 with the second to determine if it is less than the second long64.
+ * - 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.
+ * - If the first long64 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two long64 values from the operand stack.
+ * - Compares the first long64 with the second to determine if it is less than or equal to the second long64.
+ * - 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.
+ * - If the first long64 is greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the float32 addition operation on these two operands.
+ * - Pushes the result of the addition back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the float32 subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
+ * - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the float32 multiplication operation on these two operands (i.e.,
firstOperand * secondOperand).
+ * - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the float32 division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
+ * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
+ * - Pushes the result of the division back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
+ * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
+ * - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top float32 value from the operand stack.
+ * - Performs the negation of the popped value (i.e.,
-value).
+ * - Pushes the negated result back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - Retrieves the index of the local variable and the increment value from the instruction parameters.
+ * - Gets the current value of the local variable at the specified index from the local variable store.
+ * - Increments the local variable's value by the specified increment (i.e.,
+ *
localVariables[index] += increment).
+ * - Updates the local variable store with the new incremented value.
+ * - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
+ *
+ *
+ * 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:
+ *
+ * - Parses the float32 value from the instruction parameters.
+ * - Pushes the parsed float32 value onto the operand stack.
* - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
* 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:
- *
- * - Retrieves the index for the local variable from the instruction parameters.
- * - Retrieves the corresponding value from the local variable store of the current method frame.
- * - Pushes the retrieved value onto the operand stack for subsequent operations.
- * - Increments the program counter (PC) to proceed with the next sequential instruction.
- *
- *
- * 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.
@@ -1677,28 +1595,761 @@ 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:
*
- * - Parses the source and destination indices from the instruction parameters.
- * - Retrieves the value from the local variable store at the source index.
- * - Stores the retrieved value into the destination index of the local variable store.
+ * - Retrieves the index for the local variable from the instruction parameters.
+ * - Pops a float32 value from the operand stack.
+ * - Stores the value into the local variable store at the specified index of the current method frame.
* - Increments the program counter (PC) to proceed with the next sequential instruction.
*
*
* 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;
+ /**
+ * L_CE Opcode: Represents a conditional jump based on float32 equality.
+ * This opcode is implemented by the {@link LCECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two float32 values from the operand stack.
+ * - Compares the two float32 for equality.
+ * - If the float32 are equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the float32 are not equal, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on float32 comparison.
+ * - Implementing control flow structures such as if-statements and loops.
+ *
+ */
+ public static final int F_CE = 0x008A;
+ /**
+ * L_CNE Opcode: Represents a conditional jump based on float32 inequality.
+ * This opcode is implemented by the {@link LCNECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two float32 values from the operand stack.
+ * - Compares the two float32 for inequality.
+ * - If the float32 are not equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the float32 are equal, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on float32 comparison.
+ * - Implementing control flow structures such as conditional loops and if-else statements.
+ *
+ */
+ public static final int F_CNE = 0x008B;
+ /**
+ * L_CG Opcode: Represents a conditional jump based on float32 comparison (greater than).
+ * This opcode is implemented by the {@link LCGCommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two float32 values from the operand stack.
+ * - Compares the first float32 with the second to determine if it is greater.
+ * - If the first float32 is greater than the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first float32 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on float32 comparison.
+ * - Implementing control flow structures such as greater-than conditions in loops and conditional statements.
+ *
+ */
+ public static final int F_CG = 0x008C;
+ /**
+ * L_CGE Opcode: Represents a conditional jump based on float32 comparison (greater than or equal to).
+ * This opcode is implemented by the {@link LCGECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two float32 values from the operand stack.
+ * - Compares the first float32 with the second to determine if it is greater than or equal to the second float32.
+ * - If the first float32 is greater than or equal to the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first float32 is less than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on float32 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and range checks.
+ *
+ */
+ public static final int F_CGE = 0x008D;
+ /**
+ * L_CL Opcode: Represents a conditional jump based on float32 comparison (less than).
+ * This opcode is implemented by the {@link LCLCommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two float32 values from the operand stack.
+ * - Compares the first float32 with the second to determine if it is less than the second float32.
+ * - If the first float32 is less than the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first float32 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on float32 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and range validations.
+ *
+ */
+ public static final int F_CL = 0x008E;
+ /**
+ * L_CLE Opcode: Represents a conditional jump based on float32 comparison (less than or equal).
+ * This opcode is implemented by the {@link LCLECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two float32 values from the operand stack.
+ * - Compares the first float32 with the second to determine if it is less than or equal to the second float32.
+ * - If the first float32 is less than or equal to the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first float32 is greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on float32 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and boundary checks.
+ *
+ */
+ public static final int F_CLE = 0x008F;
+ // endregion
+
+ // 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:
+ *
+ * - 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).
+ * - Performs the double64 precision floating-point addition operation on these two operands.
+ * - Pushes the result of the addition back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the double64 precision floating-point subtraction operation by subtracting the subtrahend from the minuend (i.e.,
minuend - subtrahend).
+ * - Pushes the result of the subtraction back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the double64 precision floating-point multiplication operation on these two operands (i.e.,
firstOperand * secondOperand).
+ * - Pushes the result of the multiplication back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the double64 precision floating-point division operation by dividing the dividend by the divisor (i.e.,
dividend / divisor).
+ * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
+ * - Pushes the result of the division back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - 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).
+ * - Performs the modulus operation by calculating the remainder of the division of the dividend by the divisor (i.e.,
dividend % divisor).
+ * - Checks for division by zero and throws an {@link ArithmeticException} if the divisor is zero, as this operation is undefined.
+ * - Pushes the result of the modulus operation back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - Pops the top double64 value from the operand stack.
+ * - Performs the negation of the popped value (i.e.,
-value).
+ * - Pushes the negated result back onto the operand stack for later instructions to use.
+ *
+ *
+ * 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:
+ *
+ * - Retrieves the index of the local variable and the increment value from the instruction parameters.
+ * - Gets the current value of the local variable at the specified index from the local variable store.
+ * - Increments the local variable's value by the specified increment (i.e.,
+ *
localVariables[index] += increment).
+ * - Updates the local variable store with the new incremented value.
+ * - Returns the updated program counter (PC) value, typically incremented by 1, unless control flow changes.
+ *
+ *
+ * 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:
+ *
+ * - Parses the double64 value from the instruction parameters.
+ * - Pushes the parsed double64 value onto the operand stack.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Retrieves the index for the local variable from the instruction parameters.
+ * - Retrieves the corresponding value from the local variable store of the current method frame.
+ * - Pushes the retrieved value onto the operand stack for subsequent operations.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Retrieves the index for the local variable from the instruction parameters.
+ * - Pops a double64 value from the operand stack.
+ * - Stores the value into the local variable store at the specified index of the current method frame.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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;
+ /**
+ * L_CE Opcode: Represents a conditional jump based on double64 equality.
+ * This opcode is implemented by the {@link LCECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two double64 values from the operand stack.
+ * - Compares the two double64 for equality.
+ * - If the double64 are equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the double64 are not equal, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on double64 comparison.
+ * - Implementing control flow structures such as if-statements and loops.
+ *
+ */
+ public static final int D_CE = 0x00AA;
+ /**
+ * L_CNE Opcode: Represents a conditional jump based on double64 inequality.
+ * This opcode is implemented by the {@link LCNECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two double64 values from the operand stack.
+ * - Compares the two double64 for inequality.
+ * - If the double64 are not equal, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the double64 are equal, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on double64 comparison.
+ * - Implementing control flow structures such as conditional loops and if-else statements.
+ *
+ */
+ public static final int D_CNE = 0x00AB;
+ /**
+ * L_CG Opcode: Represents a conditional jump based on double64 comparison (greater than).
+ * This opcode is implemented by the {@link LCGCommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two double64 values from the operand stack.
+ * - Compares the first double64 with the second to determine if it is greater.
+ * - If the first double64 is greater than the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first double64 is not greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on double64 comparison.
+ * - Implementing control flow structures such as greater-than conditions in loops and conditional statements.
+ *
+ */
+ public static final int D_CG = 0x00AC;
+ /**
+ * L_CGE Opcode: Represents a conditional jump based on double64 comparison (greater than or equal to).
+ * This opcode is implemented by the {@link LCGECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two double64 values from the operand stack.
+ * - Compares the first double64 with the second to determine if it is greater than or equal to the second double64.
+ * - If the first double64 is greater than or equal to the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first double64 is less than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on double64 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and range checks.
+ *
+ */
+ public static final int D_CGE = 0x00AD;
+ /**
+ * L_CL Opcode: Represents a conditional jump based on double64 comparison (less than).
+ * This opcode is implemented by the {@link LCLCommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two double64 values from the operand stack.
+ * - Compares the first double64 with the second to determine if it is less than the second double64.
+ * - If the first double64 is less than the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first double64 is greater than or equal to the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on double64 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and range validations.
+ *
+ */
+ public static final int D_CL = 0x00AE;
+ /**
+ * L_CLE Opcode: Represents a conditional jump based on double64 comparison (less than or equal).
+ * This opcode is implemented by the {@link LCLECommand} class, which defines its specific execution logic.
+ *
+ * Execution Steps:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Pops two double64 values from the operand stack.
+ * - Compares the first double64 with the second to determine if it is less than or equal to the second double64.
+ * - If the first double64 is less than or equal to the second, updates the program counter (PC) to the specified target address,
+ * effectively jumping to the target instruction.
+ * - If the first double64 is greater than the second, increments the program counter to proceed with the next sequential instruction.
+ *
+ *
+ * This opcode is commonly used for:
+ *
+ * - Conditional branching in virtual machine execution based on double64 comparison.
+ * - Implementing control flow structures such as loops, conditional statements, and boundary checks.
+ *
+ */
+ public static final int D_CLE = 0x00AF;
+
+ // endregion
+ // 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:
+ *
+ * - Pop the top int32 value from the operand stack.
+ * - Convert the int32 value to a long64 value.
+ * - Push the converted long64 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top int32 value from the operand stack.
+ * - Convert the int32 value to a short16 value (this may involve truncation).
+ * - Push the converted short16 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top int32 value from the operand stack.
+ * - Convert the int32 value to a byte8 value (this may involve truncation).
+ * - Push the converted byte8 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top int32 value from the operand stack.
+ * - Convert the int32 value to a double64 value.
+ * - Push the converted double64 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top int32 value from the operand stack.
+ * - Convert the int32 value to a float32 value.
+ * - Push the converted float32 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top long64 value from the operand stack.
+ * - Convert the long64 value to an int32 value (this may involve truncation).
+ * - Push the converted int32 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top long64 value from the operand stack.
+ * - Convert the long64 value to a double64 value.
+ * - Push the converted double64 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top long64 value from the operand stack.
+ * - Convert the long64 value to a float32 value.
+ * - Push the converted float32 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top float32 value from the operand stack.
+ * - Convert the float32 value to an int32 value (this may involve truncation).
+ * - Push the converted int32 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top float32 value from the operand stack.
+ * - Convert the float32 value to a long64 value.
+ * - Push the converted long64 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top float32 value from the operand stack.
+ * - Convert the float32 value to a double64 value.
+ * - Push the converted double64 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top double64 value from the operand stack.
+ * - Convert the double64 value to an int32 value (this may involve truncation).
+ * - Push the converted int32 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top double64 value from the operand stack.
+ * - Convert the double64 value to a long64 value (this may involve truncation).
+ * - Push the converted long64 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top double64 value from the operand stack.
+ * - Convert the double64 value to a float32 value.
+ * - Push the converted float32 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top short16 value from the operand stack.
+ * - Convert the short16 value to an int32 value.
+ * - Push the converted int32 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Pop the top byte8 value from the operand stack.
+ * - Convert the byte8 value to an int32 value.
+ * - Push the converted int32 value back onto the operand stack for subsequent operations.
+ *
+ *
+ * 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:
+ *
+ * - Removes (pops) the top element from the operand stack.
+ * - Discards the popped value, as it is not stored or used further.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Retrieves the top element from the operand stack.
+ * - Duplicates the top value and pushes it back onto the stack.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Ensures that there are at least two elements on the operand stack.
+ * - Pops the two topmost values from the stack.
+ * - Pushes the two values back onto the stack in reversed order.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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:
+ *
+ * - Parses the target instruction address from the instruction parameters.
+ * - Validates the target address to ensure it is a non-negative int32.
+ * - 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.
+ * - If the target address is invalid (less than 0), logs an error message and halts execution by returning an invalid value (typically -1).
+ *
+ *
+ * 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.
@@ -1718,7 +2369,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.
@@ -1738,7 +2389,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:
+ *
+ * - Parses the source and destination indices from the instruction parameters.
+ * - Retrieves the value from the local variable store at the source index.
+ * - Stores the retrieved value into the destination index of the local variable store.
+ * - Increments the program counter (PC) to proceed with the next sequential instruction.
+ *
+ *
+ * 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.
@@ -1755,10 +2432,10 @@ public class VMOpCode {
* Serving as the final instruction in a program to indicate normal completion.
*
*/
- public static final int HALT = 255;
-
-
- // VI. Function Operations (50–59)
+ public static final int HALT = 0x0400;
+ public static final int SYSCALL = 0x0401;
+ public static final int DEBUG_TRAP = 0x0402;
+ // endregion
/**
* Default constructor for creating an instance of VMOpCode.
@@ -1767,4 +2444,4 @@ public class VMOpCode {
public VMOpCode() {
// Empty constructor
}
-}
+}
\ No newline at end of file
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 5c8c61b..a5af00b 100644
--- a/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java
+++ b/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java
@@ -1,47 +1,52 @@
package org.jcnc.snow.vm.factories;
-import org.jcnc.snow.vm.commands.arithmetic.conversion.*;
-import org.jcnc.snow.vm.interfaces.Command;
-import org.jcnc.snow.vm.commands.arithmetic.byte8.*;
-import org.jcnc.snow.vm.commands.arithmetic.double64.*;
-import org.jcnc.snow.vm.commands.arithmetic.float32.*;
-import org.jcnc.snow.vm.commands.arithmetic.int32.*;
-import org.jcnc.snow.vm.commands.arithmetic.long64.*;
-import org.jcnc.snow.vm.commands.arithmetic.short16.*;
-import org.jcnc.snow.vm.commands.bitwise.int32.IAndCommand;
-import org.jcnc.snow.vm.commands.bitwise.int32.IOrCommand;
-import org.jcnc.snow.vm.commands.bitwise.int32.IXorCommand;
-import org.jcnc.snow.vm.commands.bitwise.long64.LAndCommand;
-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.function.CallCommand;
-import org.jcnc.snow.vm.commands.function.RetCommand;
-import org.jcnc.snow.vm.commands.memory.all.MovCommand;
-import org.jcnc.snow.vm.commands.memory.byte8.BLoadCommand;
-import org.jcnc.snow.vm.commands.memory.byte8.BStoreCommand;
-import org.jcnc.snow.vm.commands.memory.double64.DLoadCommand;
-import org.jcnc.snow.vm.commands.memory.double64.DStoreCommand;
-import org.jcnc.snow.vm.commands.memory.float32.FLoadCommand;
-import org.jcnc.snow.vm.commands.memory.float32.FStoreCommand;
-import org.jcnc.snow.vm.commands.memory.int32.ILoadCommand;
-import org.jcnc.snow.vm.commands.memory.int32.IStoreCommand;
-import org.jcnc.snow.vm.commands.memory.long64.LLoadCommand;
-import org.jcnc.snow.vm.commands.memory.long64.LStoreCommand;
-import org.jcnc.snow.vm.commands.memory.short16.SLoadCommand;
-import org.jcnc.snow.vm.commands.memory.short16.SStoreCommand;
-import org.jcnc.snow.vm.commands.stack.all.DupCommand;
-import org.jcnc.snow.vm.commands.stack.all.PopCommand;
-import org.jcnc.snow.vm.commands.stack.all.SwapCommand;
-import org.jcnc.snow.vm.commands.stack.byte8.BPushCommand;
-import org.jcnc.snow.vm.commands.stack.double64.DPushCommand;
-import org.jcnc.snow.vm.commands.stack.float32.FPushCommand;
-import org.jcnc.snow.vm.commands.stack.int32.IPushCommand;
-import org.jcnc.snow.vm.commands.stack.long64.LPushCommand;
-import org.jcnc.snow.vm.commands.stack.short16.SPushCommand;
-import org.jcnc.snow.vm.commands.vm.HaltCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.*;
+import org.jcnc.snow.vm.commands.type.control.double64.*;
+import org.jcnc.snow.vm.commands.type.control.float32.*;
+import org.jcnc.snow.vm.commands.type.control.int32.*;
+import org.jcnc.snow.vm.commands.type.control.long64.*;
+import org.jcnc.snow.vm.commands.type.control.short16.*;
+import org.jcnc.snow.vm.commands.type.control.byte8.BAndCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.BOrCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.BXorCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IAndCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IOrCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IXorCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LAndCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LOrCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LXorCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SAndCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SOrCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SXorCommand;
+import org.jcnc.snow.vm.commands.flow.control.JumpCommand;
+import org.jcnc.snow.vm.commands.flow.control.CallCommand;
+import org.jcnc.snow.vm.commands.flow.control.RetCommand;
+import org.jcnc.snow.vm.commands.register.control.MovCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.BLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.BStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.double64.DLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.double64.DStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.float32.FLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.float32.FStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.ILoadCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LStoreCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SLoadCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SStoreCommand;
+import org.jcnc.snow.vm.commands.stack.control.DupCommand;
+import org.jcnc.snow.vm.commands.stack.control.PopCommand;
+import org.jcnc.snow.vm.commands.stack.control.SwapCommand;
+import org.jcnc.snow.vm.commands.type.control.byte8.BPushCommand;
+import org.jcnc.snow.vm.commands.type.control.double64.DPushCommand;
+import org.jcnc.snow.vm.commands.type.control.float32.FPushCommand;
+import org.jcnc.snow.vm.commands.type.control.int32.IPushCommand;
+import org.jcnc.snow.vm.commands.type.control.long64.LPushCommand;
+import org.jcnc.snow.vm.commands.type.control.short16.SPushCommand;
+import org.jcnc.snow.vm.commands.type.conversion.*;
+import org.jcnc.snow.vm.commands.system.control.HaltCommand;
import org.jcnc.snow.vm.engine.VMOpCode;
+import org.jcnc.snow.vm.interfaces.Command;
import java.util.Optional;
@@ -51,151 +56,204 @@ 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
+ /** Complete command table. 0x0000 – 0x04FF (inclusive). */
+ private static final Command[] COMMANDS = new Command[0x0500];
static {
- // Initialize the array with corresponding commands based on opCode values
- // 1 Arithmetic Operations (1–80)
- // 1.1 int32 (1-10)
- COMMANDS[VMOpCode.I_ADD] = new IAddCommand(); // 1
- COMMANDS[VMOpCode.I_SUB] = new ISubCommand(); // 2
- COMMANDS[VMOpCode.I_MUL] = new IMulCommand(); // 3
- COMMANDS[VMOpCode.I_DIV] = new IDivCommand(); // 4
- COMMANDS[VMOpCode.I_MOD] = new IModCommand(); // 5
- COMMANDS[VMOpCode.I_INC] = new IIncCommand(); // 6
- COMMANDS[VMOpCode.I_NEG] = new INegCommand(); // 7
- // 1.2 long64 (11-20)
- COMMANDS[VMOpCode.L_ADD] = new LAddCommand(); // 11
- COMMANDS[VMOpCode.L_SUB] = new LSubCommand(); // 12
- COMMANDS[VMOpCode.L_MUL] = new LMulCommand(); // 13
- COMMANDS[VMOpCode.L_DIV] = new LDivCommand(); // 14
- COMMANDS[VMOpCode.L_MOD] = new LModCommand(); // 15
- COMMANDS[VMOpCode.L_INC] = new LIncCommand(); // 16
- COMMANDS[VMOpCode.L_NEG] = new LNegCommand(); // 17
- // 1.3 short16 (21-30)
- COMMANDS[VMOpCode.S_ADD] = new SAddCommand(); // 21
- COMMANDS[VMOpCode.S_SUB] = new SSubCommand(); // 22
- COMMANDS[VMOpCode.S_MUL] = new SMulCommand(); // 23
- COMMANDS[VMOpCode.S_DIV] = new SDivCommand(); // 24
- COMMANDS[VMOpCode.S_MOD] = new SModCommand(); // 25
- COMMANDS[VMOpCode.S_INC] = new SIncCommand(); // 26
- COMMANDS[VMOpCode.S_NEG] = new SNegCommand(); // 27
- // 1.4 byte8 (31-40)
- COMMANDS[VMOpCode.B_ADD] = new BAddCommand(); // 31
- COMMANDS[VMOpCode.B_SUB] = new BSubCommand(); // 32
- COMMANDS[VMOpCode.B_MUL] = new BMulCommand(); // 33
- COMMANDS[VMOpCode.B_DIV] = new BDivCommand(); // 34
- COMMANDS[VMOpCode.B_MOD] = new BModCommand(); // 35
- COMMANDS[VMOpCode.B_INC] = new BIncCommand(); // 36
- COMMANDS[VMOpCode.B_NEG] = new BNegCommand(); // 37
- // 1.5 double64 (41-50)
- COMMANDS[VMOpCode.D_ADD] = new DAddCommand(); // 41
- COMMANDS[VMOpCode.D_SUB] = new DSubCommand(); // 42
- COMMANDS[VMOpCode.D_MUL] = new DMulCommand(); // 43
- COMMANDS[VMOpCode.D_DIV] = new DDivCommand(); // 44
- COMMANDS[VMOpCode.D_MOD] = new DModCommand(); // 45
- COMMANDS[VMOpCode.D_INC] = new DIncCommand(); // 46
- COMMANDS[VMOpCode.D_NEG] = new DNegCommand(); // 47
- // 1.6 float32 (51-60)
- COMMANDS[VMOpCode.F_ADD] = new FAddCommand(); // 51
- COMMANDS[VMOpCode.F_SUB] = new FSubCommand(); // 52
- COMMANDS[VMOpCode.F_MUL] = new FMulCommand(); // 53
- COMMANDS[VMOpCode.F_DIV] = new FDivCommand(); // 54
- COMMANDS[VMOpCode.F_MOD] = new FModCommand(); // 55
- COMMANDS[VMOpCode.F_INC] = new FIncCommand(); // 56
- COMMANDS[VMOpCode.F_NEG] = new FNegCommand(); // 57
+ // region Type Control (0x0000-0x00BF)
+ // region Byte8 (0x0000-0x001F)
+ COMMANDS[VMOpCode.B_ADD] = new BAddCommand();
+ COMMANDS[VMOpCode.B_SUB] = new BSubCommand();
+ COMMANDS[VMOpCode.B_MUL] = new BMulCommand();
+ COMMANDS[VMOpCode.B_DIV] = new BDivCommand();
+ COMMANDS[VMOpCode.B_MOD] = new BModCommand();
+ COMMANDS[VMOpCode.B_NEG] = new BNegCommand();
+ COMMANDS[VMOpCode.B_INC] = new BIncCommand();
- // 1.7 Type Conversion (61-80)
- COMMANDS[VMOpCode.I2L] = new I2LCommand(); // 61 int -> long
- COMMANDS[VMOpCode.I2S] = new I2SCommand(); // 62 int -> short
- COMMANDS[VMOpCode.I2B] = new I2BCommand(); // 63 int -> byte
- COMMANDS[VMOpCode.I2D] = new I2DCommand(); // 64 int -> double
- COMMANDS[VMOpCode.I2F] = new I2FCommand(); // 65 int -> float
+ COMMANDS[VMOpCode.B_AND] = new BAndCommand();
+ COMMANDS[VMOpCode.B_OR] = new BOrCommand();
+ COMMANDS[VMOpCode.B_XOR] = new BXorCommand();
- COMMANDS[VMOpCode.L2I] = new L2ICommand(); // 66 long -> int
- COMMANDS[VMOpCode.L2D] = new L2DCommand(); // 67 long -> double
- COMMANDS[VMOpCode.L2F] = new L2FCommand(); // 68 long -> float
+ COMMANDS[VMOpCode.B_PUSH] = new BPushCommand();
+ COMMANDS[VMOpCode.B_LOAD] = new BLoadCommand();
+ COMMANDS[VMOpCode.B_STORE] = new BStoreCommand();
- COMMANDS[VMOpCode.F2I] = new F2ICommand(); // 69 float -> int
- COMMANDS[VMOpCode.F2L] = new F2LCommand(); // 70 float -> long
- COMMANDS[VMOpCode.F2D] = new F2DCommand(); // 71 float -> double
+ COMMANDS[VMOpCode.B_CE] = new BCECommand();
+ COMMANDS[VMOpCode.B_CNE] = new BCNECommand();
+ COMMANDS[VMOpCode.B_CG] = new BCGCommand();
+ COMMANDS[VMOpCode.B_CGE] = new BCGECommand();
+ COMMANDS[VMOpCode.B_CL] = new BCLCommand();
+ COMMANDS[VMOpCode.B_CLE] = new BCLECommand();
- COMMANDS[VMOpCode.D2I] = new D2ICommand(); // 72 double -> int
- COMMANDS[VMOpCode.D2L] = new D2LCommand(); // 73 double -> long
- COMMANDS[VMOpCode.D2F] = new D2FCommand(); // 74 double -> float
+ // endregion
- COMMANDS[VMOpCode.S2I] = new S2ICommand(); // 75 short -> int
+ // region Short16 (0x0020-0x003F)
+ COMMANDS[VMOpCode.S_ADD] = new SAddCommand();
+ COMMANDS[VMOpCode.S_SUB] = new SSubCommand();
+ COMMANDS[VMOpCode.S_MUL] = new SMulCommand();
+ COMMANDS[VMOpCode.S_DIV] = new SDivCommand();
+ COMMANDS[VMOpCode.S_MOD] = new SModCommand();
+ COMMANDS[VMOpCode.S_NEG] = new SNegCommand();
+ COMMANDS[VMOpCode.S_INC] = new SIncCommand();
- COMMANDS[VMOpCode.B2I] = new B2ICommand(); // 76 byte -> int
+ COMMANDS[VMOpCode.S_AND] = new SAndCommand();
+ COMMANDS[VMOpCode.S_OR] = new SOrCommand();
+ COMMANDS[VMOpCode.S_XOR] = new SXorCommand();
- // 1.8 Other (77-80)
+ COMMANDS[VMOpCode.S_PUSH] = new SPushCommand();
+ COMMANDS[VMOpCode.S_LOAD] = new SLoadCommand();
+ COMMANDS[VMOpCode.S_STORE] = new SStoreCommand();
- // 2. Bitwise Operations (81–90)
- // 2.1 int32 (81-85)
- COMMANDS[VMOpCode.I_AND] = new IAndCommand(); // 81
- COMMANDS[VMOpCode.I_OR] = new IOrCommand(); // 82
- COMMANDS[VMOpCode.I_XOR] = new IXorCommand(); // 83
- // 2.2 Long64 (86-90)
- COMMANDS[VMOpCode.L_AND] = new LAndCommand(); // 86
- COMMANDS[VMOpCode.L_OR] = new LOrCommand(); // 87
- COMMANDS[VMOpCode.L_XOR] = new LXorCommand(); // 88
+ COMMANDS[VMOpCode.S_CE] = new SCECommand();
+ COMMANDS[VMOpCode.S_CNE] = new SCNECommand();
+ COMMANDS[VMOpCode.S_CG] = new SCGCommand();
+ COMMANDS[VMOpCode.S_CGE] = new SCGECommand();
+ COMMANDS[VMOpCode.S_CL] = new SCLCommand();
+ COMMANDS[VMOpCode.S_CLE] = new SCLECommand();
+ // endregion
- // 3. Control Flow Operations (91–110)
- COMMANDS[VMOpCode.JUMP] = new JumpCommand(); // 91
- 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
+ // region Int32 (0x0040-0x005F)
+ COMMANDS[VMOpCode.I_ADD] = new IAddCommand();
+ COMMANDS[VMOpCode.I_SUB] = new ISubCommand();
+ COMMANDS[VMOpCode.I_MUL] = new IMulCommand();
+ COMMANDS[VMOpCode.I_DIV] = new IDivCommand();
+ COMMANDS[VMOpCode.I_MOD] = new IModCommand();
+ COMMANDS[VMOpCode.I_NEG] = new INegCommand();
+ COMMANDS[VMOpCode.I_INC] = new IIncCommand();
- // 4. Stack Operations (111–150)
- // 4.1 PUSH (111-120)
- COMMANDS[VMOpCode.I_PUSH] = new IPushCommand(); // 111
- COMMANDS[VMOpCode.L_PUSH] = new LPushCommand(); // 112
- COMMANDS[VMOpCode.S_PUSH] = new SPushCommand(); // 113
- COMMANDS[VMOpCode.B_PUSH] = new BPushCommand(); // 114
- COMMANDS[VMOpCode.D_PUSH] = new DPushCommand(); // 115
- COMMANDS[VMOpCode.F_PUSH] = new FPushCommand(); // 116
- // 4.2 POP (121-125)
- COMMANDS[VMOpCode.POP] = new PopCommand(); // 121
- // 4.3 DUP (126-130)
- COMMANDS[VMOpCode.DUP] = new DupCommand(); // 126
- // 4.4 SWAP (131-135)
- COMMANDS[VMOpCode.SWAP] = new SwapCommand(); // 131
+ COMMANDS[VMOpCode.I_AND] = new IAndCommand();
+ COMMANDS[VMOpCode.I_OR] = new IOrCommand();
+ COMMANDS[VMOpCode.I_XOR] = new IXorCommand();
- // 4.5 Other (136-150)
+ COMMANDS[VMOpCode.I_PUSH] = new IPushCommand();
+ COMMANDS[VMOpCode.I_LOAD] = new ILoadCommand();
+ COMMANDS[VMOpCode.I_STORE] = new IStoreCommand();
- // 5. Memory Operations (151–200)
- // 5.1 STORE (151-160)
- COMMANDS[VMOpCode.I_STORE] = new IStoreCommand(); // 151
- COMMANDS[VMOpCode.L_STORE] = new LStoreCommand(); // 152
- COMMANDS[VMOpCode.S_STORE] = new SStoreCommand(); // 153
- COMMANDS[VMOpCode.B_STORE] = new BStoreCommand(); // 154
- COMMANDS[VMOpCode.D_STORE] = new DStoreCommand(); // 155
- COMMANDS[VMOpCode.F_STORE] = new FStoreCommand(); // 156
- // 5.2 LOAD (161-170)
- COMMANDS[VMOpCode.I_LOAD] = new ILoadCommand(); // 161
- COMMANDS[VMOpCode.L_LOAD] = new LLoadCommand(); // 162
- COMMANDS[VMOpCode.S_LOAD] = new SLoadCommand(); // 163
- COMMANDS[VMOpCode.B_LOAD] = new BLoadCommand(); // 164
- COMMANDS[VMOpCode.D_LOAD] = new DLoadCommand(); // 165
- COMMANDS[VMOpCode.F_LOAD] = new FLoadCommand(); // 166
+ COMMANDS[VMOpCode.I_CE] = new ICECommand();
+ COMMANDS[VMOpCode.I_CNE] = new ICNECommand();
+ COMMANDS[VMOpCode.I_CG] = new ICGCommand();
+ COMMANDS[VMOpCode.I_CGE] = new ICGECommand();
+ COMMANDS[VMOpCode.I_CL] = new ICLCommand();
+ COMMANDS[VMOpCode.I_CLE] = new ICLECommand();
+ // endregion
- // 5.3 MOV (171-176)
- COMMANDS[VMOpCode.MOV] = new MovCommand(); // 171
+ // region Long64 (0x0060-0x007F)
+ COMMANDS[VMOpCode.L_ADD] = new LAddCommand();
+ COMMANDS[VMOpCode.L_SUB] = new LSubCommand();
+ COMMANDS[VMOpCode.L_MUL] = new LMulCommand();
+ COMMANDS[VMOpCode.L_DIV] = new LDivCommand();
+ COMMANDS[VMOpCode.L_MOD] = new LModCommand();
+ COMMANDS[VMOpCode.L_NEG] = new LNegCommand();
+ COMMANDS[VMOpCode.L_INC] = new LIncCommand();
- // 5.4 Other (176-200)
+ COMMANDS[VMOpCode.L_AND] = new LAndCommand();
+ COMMANDS[VMOpCode.L_OR] = new LOrCommand();
+ COMMANDS[VMOpCode.L_XOR] = new LXorCommand();
- // 6. Function Operations (201–205)
- COMMANDS[VMOpCode.CALL] = new CallCommand(); // 201
- COMMANDS[VMOpCode.RET] = new RetCommand(); // 202
+ COMMANDS[VMOpCode.L_PUSH] = new LPushCommand();
+ COMMANDS[VMOpCode.L_LOAD] = new LLoadCommand();
+ COMMANDS[VMOpCode.L_STORE] = new LStoreCommand();
+
+ COMMANDS[VMOpCode.L_CE] = new LCECommand();
+ COMMANDS[VMOpCode.L_CNE] = new LCNECommand();
+ COMMANDS[VMOpCode.L_CG] = new LCGCommand();
+ COMMANDS[VMOpCode.L_CGE] = new LCGECommand();
+ COMMANDS[VMOpCode.L_CL] = new LCLCommand();
+ COMMANDS[VMOpCode.L_CLE] = new LCLECommand();
+ // endregion
+
+ // region Float32 (0x0080-0x009F)
+ COMMANDS[VMOpCode.F_ADD] = new FAddCommand();
+ COMMANDS[VMOpCode.F_SUB] = new FSubCommand();
+ COMMANDS[VMOpCode.F_MUL] = new FMulCommand();
+ COMMANDS[VMOpCode.F_DIV] = new FDivCommand();
+ COMMANDS[VMOpCode.F_MOD] = new FModCommand();
+ COMMANDS[VMOpCode.F_NEG] = new FNegCommand();
+ COMMANDS[VMOpCode.F_INC] = new FIncCommand();
+
+ COMMANDS[VMOpCode.F_PUSH] = new FPushCommand();
+ COMMANDS[VMOpCode.F_LOAD] = new FLoadCommand();
+ COMMANDS[VMOpCode.F_STORE] = new FStoreCommand();
+
+ COMMANDS[VMOpCode.F_CE] = new FCECommand();
+ COMMANDS[VMOpCode.F_CNE] = new FCNECommand();
+ COMMANDS[VMOpCode.F_CG] = new FCGCommand();
+ COMMANDS[VMOpCode.F_CGE] = new FCGECommand();
+ COMMANDS[VMOpCode.F_CL] = new FCLCommand();
+ COMMANDS[VMOpCode.F_CLE] = new FCLECommand();
+ // endregion
+
+ // region Double64 (0x00A0-0x00BF)
+ COMMANDS[VMOpCode.D_ADD] = new DAddCommand();
+ COMMANDS[VMOpCode.D_SUB] = new DSubCommand();
+ COMMANDS[VMOpCode.D_MUL] = new DMulCommand();
+ COMMANDS[VMOpCode.D_DIV] = new DDivCommand();
+ COMMANDS[VMOpCode.D_MOD] = new DModCommand();
+ COMMANDS[VMOpCode.D_NEG] = new DNegCommand();
+ COMMANDS[VMOpCode.D_INC] = new DIncCommand();
+
+ COMMANDS[VMOpCode.D_PUSH] = new DPushCommand();
+ COMMANDS[VMOpCode.D_LOAD] = new DLoadCommand();
+ COMMANDS[VMOpCode.D_STORE] = new DStoreCommand();
+
+ COMMANDS[VMOpCode.D_CE] = new DCECommand();
+ COMMANDS[VMOpCode.D_CNE] = new DCNECommand();
+ COMMANDS[VMOpCode.D_CG] = new DCGCommand();
+ COMMANDS[VMOpCode.D_CGE] = new DCGECommand();
+ COMMANDS[VMOpCode.D_CL] = new DCLCommand();
+ COMMANDS[VMOpCode.D_CLE] = new DCLECommand();
+ // endregion
+ // endregion
+
+ // region Type Conversion (0x00C0-0x00DF)
+ COMMANDS[VMOpCode.I2L] = new I2LCommand();
+ COMMANDS[VMOpCode.I2S] = new I2SCommand();
+ COMMANDS[VMOpCode.I2B] = new I2BCommand();
+ COMMANDS[VMOpCode.I2D] = new I2DCommand();
+ COMMANDS[VMOpCode.I2F] = new I2FCommand();
+
+ COMMANDS[VMOpCode.L2I] = new L2ICommand();
+ COMMANDS[VMOpCode.L2D] = new L2DCommand();
+ COMMANDS[VMOpCode.L2F] = new L2FCommand();
+
+ COMMANDS[VMOpCode.F2I] = new F2ICommand();
+ COMMANDS[VMOpCode.F2L] = new F2LCommand();
+ COMMANDS[VMOpCode.F2D] = new F2DCommand();
+
+ COMMANDS[VMOpCode.D2I] = new D2ICommand();
+ COMMANDS[VMOpCode.D2L] = new D2LCommand();
+ COMMANDS[VMOpCode.D2F] = new D2FCommand();
+
+ COMMANDS[VMOpCode.S2I] = new S2ICommand();
+ COMMANDS[VMOpCode.B2I] = new B2ICommand();
+ // endregion
+
+ // region Stack Control (0x0100-0x01FF)
+ COMMANDS[VMOpCode.POP] = new PopCommand();
+ COMMANDS[VMOpCode.DUP] = new DupCommand();
+ COMMANDS[VMOpCode.SWAP] = new SwapCommand();
+ // endregion
+
+ // region Flow Control (0x0200-0x02FF)
+ COMMANDS[VMOpCode.JUMP] = new JumpCommand();
+ COMMANDS[VMOpCode.CALL] = new CallCommand();
+ COMMANDS[VMOpCode.RET] = new RetCommand();
+ // endregion
+
+ // region Register Control (0x0300-0x03FF)
+ COMMANDS[VMOpCode.MOV] = new MovCommand();
+ // endregion
+
+ // region System Control (0x0400-0x04FF)
+ COMMANDS[VMOpCode.HALT] = new HaltCommand();
+// COMMANDS[VMOpCode.SYSCALL] = new SyscallCommand();
+// COMMANDS[VMOpCode.DEBUG_TRAP] = new DebugTrapCommand();
+ // endregion
- // 7. Virtual Machine Operations(241-255)
- COMMANDS[VMOpCode.HALT] = new HaltCommand(); // 255
}
+
/**
* Default constructor for creating an instance of CommandFactory.
* This constructor is empty as no specific initialization is required.
diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties
new file mode 100644
index 0000000..bdb6c2f
--- /dev/null
+++ b/src/main/resources/version.properties
@@ -0,0 +1 @@
+snow.version=${project.version}