INVERT = Map.ofEntries(
+ // 32-bit
+ Map.entry(IROpCode.CMP_IEQ, IROpCode.CMP_INE),
+ Map.entry(IROpCode.CMP_INE, IROpCode.CMP_IEQ),
+ Map.entry(IROpCode.CMP_ILT, IROpCode.CMP_IGE),
+ Map.entry(IROpCode.CMP_IGE, IROpCode.CMP_ILT),
+ Map.entry(IROpCode.CMP_IGT, IROpCode.CMP_ILE),
+ Map.entry(IROpCode.CMP_ILE, IROpCode.CMP_IGT),
+ // 64-bit
+ Map.entry(IROpCode.CMP_LEQ, IROpCode.CMP_LNE),
+ Map.entry(IROpCode.CMP_LNE, IROpCode.CMP_LEQ),
+ Map.entry(IROpCode.CMP_LLT, IROpCode.CMP_LGE),
+ Map.entry(IROpCode.CMP_LGE, IROpCode.CMP_LLT),
+ Map.entry(IROpCode.CMP_LGT, IROpCode.CMP_LLE),
+ Map.entry(IROpCode.CMP_LLE, IROpCode.CMP_LGT)
);
/**
diff --git a/src/main/java/org/jcnc/snow/compiler/semantic/analyzers/expression/BinaryExpressionAnalyzer.java b/src/main/java/org/jcnc/snow/compiler/semantic/analyzers/expression/BinaryExpressionAnalyzer.java
index 2bc22de..c14b83b 100644
--- a/src/main/java/org/jcnc/snow/compiler/semantic/analyzers/expression/BinaryExpressionAnalyzer.java
+++ b/src/main/java/org/jcnc/snow/compiler/semantic/analyzers/expression/BinaryExpressionAnalyzer.java
@@ -11,79 +11,75 @@ import org.jcnc.snow.compiler.semantic.type.BuiltinType;
import org.jcnc.snow.compiler.semantic.type.Type;
/**
- * {@code BinaryExpressionAnalyzer} 是一个用于分析二元表达式的语义分析器。
+ * {@code BinaryExpressionAnalyzer} 负责对二元表达式做语义分析并返回其类型。
*
- * 支持的特性包括:
- *
- * - 字符串拼接(当运算符为加号 "+" 且任一操作数为字符串类型时)
- * - 数值类型的自动宽化转换(如 int 与 float 运算将转换为 float)
- * - 基本的数值运算符(如 +, -, *, /, %)
- * - 关系运算符和比较运算符(如 <, <=, >, >=, ==, !=)
- *
- * 对于不支持的运算符或不兼容的类型组合,将记录语义错误,并默认返回 {@code BuiltinType.INT} 以保持分析过程的连续性。
+ * 支持特性:
+ * 1. 字符串拼接「+」
+ * 2. 数值运算与自动宽化
+ * 3. 比较 / 关系运算
+ * 4. 布尔值比较(== / !=)
*
- * 实现类遵循 {@code ExpressionAnalyzer} 接口规范。
+ * 如遇不支持的运算符或不兼容的类型组合,将记录语义错误,
+ * 并以 {@code int} 作为回退类型,保持后续分析不中断。
*/
public class BinaryExpressionAnalyzer implements ExpressionAnalyzer {
- /**
- * 分析给定的二元表达式节点,返回其表达式类型。
- *
- * @param ctx 当前语义分析上下文,用于访问日志记录、错误收集、注册表等服务。
- * @param mi 当前模块信息,包含模块级别的符号与类型定义。
- * @param fn 当前正在分析的函数节点。
- * @param locals 当前函数作用域内的符号表,用于变量查找。
- * @param bin 要分析的二元表达式节点。
- * @return 分析后推断出的表达式类型。
- */
@Override
public Type analyze(Context ctx,
ModuleInfo mi,
FunctionNode fn,
SymbolTable locals,
BinaryExpressionNode bin) {
+
ctx.log("检查二元表达式: " + bin.operator());
- // 获取左侧表达式类型
- Type left = ctx.getRegistry().getExpressionAnalyzer(bin.left())
+ /* ----------- 先递归分析左右子表达式类型 ----------- */
+ Type left = ctx.getRegistry()
+ .getExpressionAnalyzer(bin.left())
.analyze(ctx, mi, fn, locals, bin.left());
- // 获取右侧表达式类型
- Type right = ctx.getRegistry().getExpressionAnalyzer(bin.right())
+ Type right = ctx.getRegistry()
+ .getExpressionAnalyzer(bin.right())
.analyze(ctx, mi, fn, locals, bin.right());
String op = bin.operator();
- // 情况 1:字符串拼接(+ 操作符且任一操作数为字符串类型)
+ /* ----------- 情况 1:字符串拼接 ----------- */
if (op.equals("+") &&
(left == BuiltinType.STRING || right == BuiltinType.STRING)) {
return BuiltinType.STRING;
}
- // 情况 2:数值类型运算或比较
+ /* ----------- 情况 1.5:布尔值比较 ----------- */
+ if (("==".equals(op) || "!=".equals(op)) &&
+ left == BuiltinType.BOOLEAN &&
+ right == BuiltinType.BOOLEAN) {
+ return BuiltinType.BOOLEAN;
+ }
+
+ /* ----------- 情况 2:数值运算 / 比较 ----------- */
if ("+-*/%".contains(op) || ("<<=>>===!=").contains(op)) {
if (left.isNumeric() && right.isNumeric()) {
- // 自动宽化到更宽的数值类型(如 int + float => float)
+ // 自动数值宽化(如 int + float → float)
Type wide = Type.widen(left, right);
- if (wide == null) wide = BuiltinType.INT; // 容错降级为 int
+ if (wide == null) wide = BuiltinType.INT; // 容错降级
- // 若为比较运算符,统一返回 boolean 类型作为布尔值表示
+ // 比较运算统一返回 boolean
if ("< <= > >= == !=".contains(op)) {
return BuiltinType.BOOLEAN;
}
-
return wide;
}
}
- // 情况 3:不支持的类型组合,记录语义错误
+ /* ----------- 情况 3:不支持的类型组合 ----------- */
ctx.getErrors().add(new SemanticError(
bin,
String.format("运算符 '%s' 不支持类型: %s 和 %s", op, left, right)
));
ctx.log("错误: 运算符 '" + op + "' 不支持类型: " + left + ", " + right);
- // 错误情况下默认返回 int 类型,以保证语义分析不中断
+ // 回退类型
return BuiltinType.INT;
}
}
diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java
index b05f809..f2a42ca 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java
@@ -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/arithmetic/byte8/BDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java
index ad24912..582951b 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java
@@ -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/BModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java
index 88b12bd..dd5892f 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java
@@ -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/arithmetic/byte8/BMulCommand.java
index e5de63a..0c6d9c3 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java
@@ -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/BSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java
index 091cafd..4c7957e 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java
@@ -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/arithmetic/short16/SAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java
index 4137a01..b4b1290 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java
@@ -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/arithmetic/short16/SDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java
index f14cefa..9c71b8c 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java
@@ -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/SModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java
index 0047449..105b5bc 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java
@@ -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/arithmetic/short16/SMulCommand.java
index 1a2ac4e..f6c022d 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java
@@ -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/SSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java
index 66c3295..53953b3 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java
@@ -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/control/byte8/BCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCECommand.java
new file mode 100644
index 0000000..f7ccc5b
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/byte8/BCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCGCommand.java
new file mode 100644
index 0000000..92fb765
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/byte8/BCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCGECommand.java
new file mode 100644
index 0000000..16f468e
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/byte8/BCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCLCommand.java
new file mode 100644
index 0000000..1753865
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/byte8/BCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCLECommand.java
new file mode 100644
index 0000000..bb90118
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/byte8/BCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCNECommand.java
new file mode 100644
index 0000000..a474570
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/byte8/BCNECommand.java
@@ -0,0 +1,77 @@
+package org.jcnc.snow.vm.commands.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/control/double64/DCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCECommand.java
new file mode 100644
index 0000000..0153626
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/double64/DCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCGCommand.java
new file mode 100644
index 0000000..fd48bff
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/double64/DCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCGECommand.java
new file mode 100644
index 0000000..03dad61
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/double64/DCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCLCommand.java
new file mode 100644
index 0000000..344df6c
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/double64/DCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCLECommand.java
new file mode 100644
index 0000000..3d87f1a
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/double64/DCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCNECommand.java
new file mode 100644
index 0000000..1da0475
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/double64/DCNECommand.java
@@ -0,0 +1,77 @@
+package org.jcnc.snow.vm.commands.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/control/float32/FCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCECommand.java
new file mode 100644
index 0000000..6c8620d
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/float32/FCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCGCommand.java
new file mode 100644
index 0000000..2b9b71f
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/float32/FCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCGECommand.java
new file mode 100644
index 0000000..45d5fc1
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/float32/FCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCLCommand.java
new file mode 100644
index 0000000..26cc4bb
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/float32/FCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCLECommand.java
new file mode 100644
index 0000000..becc5d5
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/float32/FCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCNECommand.java
new file mode 100644
index 0000000..d75ac57
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/float32/FCNECommand.java
@@ -0,0 +1,77 @@
+package org.jcnc.snow.vm.commands.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/control/int32/ICECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICECommand.java
index 6e923af..fc1636e 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICECommand.java
@@ -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/control/int32/ICGCommand.java
index a339313..574151e 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGCommand.java
@@ -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/control/int32/ICGECommand.java
index 3cfe02d..8f28127 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICGECommand.java
@@ -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/control/int32/ICLCommand.java
index ec3d413..e1909e9 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLCommand.java
@@ -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/control/int32/ICLECommand.java
index 4e6c007..0410d1f 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICLECommand.java
@@ -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/control/int32/ICNECommand.java
index 08a46a9..b921efc 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICNECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/int32/ICNECommand.java
@@ -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/control/long64/LCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCECommand.java
index 33ecbfc..9eb73e3 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCECommand.java
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.utils.LoggingUtils;
*
* Specific behavior:
*
- * - Pops two integers from the virtual machine stack.
- * - If the two integers are equal, jumps to the target command.
+ * - 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.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCGCommand.java
index c9abdee..83b99e4 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCGCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCGCommand.java
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.utils.LoggingUtils;
*
* 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 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.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCGECommand.java
index 89f50d3..3ce9e90 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCGECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCGECommand.java
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.utils.LoggingUtils;
*
* 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 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.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCLCommand.java
index 1467371..b52eb64 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCLCommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCLCommand.java
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.utils.LoggingUtils;
*
* 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 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.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCLECommand.java
index 634b183..e585fd7 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCLECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCLECommand.java
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.utils.LoggingUtils;
*
* 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 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.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCNECommand.java
index 7aba528..4031630 100644
--- a/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCNECommand.java
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/long64/LCNECommand.java
@@ -12,8 +12,8 @@ import org.jcnc.snow.vm.utils.LoggingUtils;
*
* Specific behavior:
*
- * - Pops two integers from the virtual machine stack.
- * - If the two integers are not equal, jumps to the target command.
+ * - 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.
*
*/
diff --git a/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCECommand.java
new file mode 100644
index 0000000..d1715a9
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/short16/SCGCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCGCommand.java
new file mode 100644
index 0000000..42cc70a
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCGCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/short16/SCGECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCGECommand.java
new file mode 100644
index 0000000..78e8add
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCGECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/short16/SCLCommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCLCommand.java
new file mode 100644
index 0000000..96c7a24
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCLCommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/short16/SCLECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCLECommand.java
new file mode 100644
index 0000000..33de323
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCLECommand.java
@@ -0,0 +1,76 @@
+package org.jcnc.snow.vm.commands.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/control/short16/SCNECommand.java b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCNECommand.java
new file mode 100644
index 0000000..9bb3f51
--- /dev/null
+++ b/src/main/java/org/jcnc/snow/vm/commands/control/short16/SCNECommand.java
@@ -0,0 +1,77 @@
+package org.jcnc.snow.vm.commands.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/engine/VMOpCode.java b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java
index 1b2f458..f5e8762 100644
--- a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java
+++ b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java
@@ -47,8 +47,8 @@ import org.jcnc.snow.vm.module.LocalVariableStore;
* Each opcode represents a specific operation executed by the virtual machine.
*/
public class VMOpCode {
- // 1 Arithmetic Operations (1–80)
- // 1.1 int32 (1-10)
+ // region 1. Arithmetic Operations (1–100)
+ // region 1.1 int32 (0-9)
/**
* I_ADD Opcode: Represents the int32 addition operation in the virtual machine.
* This opcode is implemented by the {@link IAddCommand} class, which defines its specific execution logic.
@@ -63,7 +63,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic int32 addition tasks.
*/
- public static final int I_ADD = 1;
+ public static final int I_ADD = 0;
/**
* I_SUB Opcode: Represents the int32 subtraction operation in the virtual machine.
* This opcode is implemented by the {@link ISubCommand} class, which defines its specific execution logic.
@@ -78,7 +78,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic int32 subtraction tasks.
*/
- public static final int I_SUB = 2;
+ public static final int I_SUB = 1;
/**
* I_MUL Opcode: Represents the int32 multiplication operation in the virtual machine.
* This opcode is implemented by the {@link IMulCommand} class, which defines its specific execution logic.
@@ -93,7 +93,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic int32 multiplication tasks.
*/
- public static final int I_MUL = 3;
+ public static final int I_MUL = 2;
/**
* I_DIV Opcode: Represents the int32 division operation in the virtual machine.
* This opcode is implemented by the {@link IDivCommand} class, which defines its specific execution logic.
@@ -109,7 +109,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic int32 division tasks.
*/
- public static final int I_DIV = 4;
+ public static final int I_DIV = 3;
/**
* I_MOD Opcode: Represents the int32 modulus (remainder) operation in the virtual machine.
* This opcode is implemented by the {@link IModCommand} class, which defines its specific execution logic.
@@ -125,7 +125,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic int32 modulus (remainder) tasks.
*/
- public static final int I_MOD = 5;
+ public static final int I_MOD = 4;
/**
* I_INC Opcode: Represents the int32 increment operation for a local variable in the virtual machine.
* This opcode is implemented by the {@link IIncCommand} class, which defines its specific execution logic.
@@ -142,8 +142,7 @@ public class VMOpCode {
*
* This opcode is particularly useful for optimizing scenarios where a local variable, such as a counter or loop index, is frequently incremented.
*/
- public static final int I_INC = 6;
-
+ public static final int I_INC = 5;
/**
* I_NEG Opcode: Represents the int32 negation operation in the virtual machine.
* This opcode is implemented by the {@link INegCommand} class, which defines its specific execution logic.
@@ -157,8 +156,10 @@ public class VMOpCode {
*
* This opcode is typically used to negate an int32 value, making it a fundamental operation for arithmetic logic within the virtual machine.
*/
- public static final int I_NEG = 7;
- // 1.2 long64 (11-20)
+ public static final int I_NEG = 6;
+ // endregion
+
+ // region 1.2 long64 (10-19)
/**
* L_ADD Opcode: Represents the long64 addition operation in the virtual machine.
* This opcode is implemented by the {@link LAddCommand} class, which defines its specific execution logic.
@@ -173,8 +174,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic long64 addition tasks.
*/
- public static final int L_ADD = 11;
-
+ public static final int L_ADD = 10;
/**
* L_SUB Opcode: Represents the long64 subtraction operation in the virtual machine.
* This opcode is implemented by the {@link LSubCommand} class, which defines its specific execution logic.
@@ -189,8 +189,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic long64 subtraction tasks.
*/
- public static final int L_SUB = 12;
-
+ public static final int L_SUB = 11;
/**
* L_MUL Opcode: Represents the long64 multiplication operation in the virtual machine.
* This opcode is implemented by the {@link LMulCommand} class, which defines its specific execution logic.
@@ -205,8 +204,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic long64 multiplication tasks.
*/
- public static final int L_MUL = 13;
-
+ public static final int L_MUL = 12;
/**
* L_DIV Opcode: Represents the long64 division operation in the virtual machine.
* This opcode is implemented by the {@link LDivCommand} class, which defines its specific execution logic.
@@ -222,8 +220,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic long64 division tasks.
*/
- public static final int L_DIV = 14;
-
+ public static final int L_DIV = 13;
/**
* L_MOD Opcode: Represents the long64 modulus (remainder) operation in the virtual machine.
* This opcode is implemented by the {@link LModCommand} class, which defines its specific execution logic.
@@ -239,8 +236,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic long64 modulus (remainder) tasks.
*/
- public static final int L_MOD = 15;
-
+ public static final int L_MOD = 14;
/**
* L_INC Opcode: Represents the long64 increment operation for a local variable in the virtual machine.
* This opcode is implemented by the {@link LIncCommand} class, which defines its specific execution logic.
@@ -257,9 +253,7 @@ public class VMOpCode {
*
* This opcode is particularly useful for optimizing scenarios where a local `long64` variable, such as a counter or loop index, is frequently incremented.
*/
- public static final int L_INC = 16;
-
-
+ public static final int L_INC = 15;
/**
* L_NEG Opcode: Represents the long64 negation operation in the virtual machine.
* This opcode is implemented by the {@link LNegCommand} class, which defines its specific execution logic.
@@ -273,9 +267,10 @@ public class VMOpCode {
*
* This opcode is typically used to negate a long64 value, making it a fundamental operation for arithmetic logic within the virtual machine.
*/
- public static final int L_NEG = 17;
+ public static final int L_NEG = 16;
+ // endregion
- // 1.3 short16 (21-30)
+ // region 1.3 short16 (20-29)
/**
* S_ADD Opcode: Represents the short16 addition operation in the virtual machine.
* This opcode is implemented by the {@link SAddCommand} class, which defines its specific execution logic.
@@ -290,8 +285,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic short16 addition tasks.
*/
- public static final int S_ADD = 21;
-
+ public static final int S_ADD = 20;
/**
* S_SUB Opcode: Represents the short16 subtraction operation in the virtual machine.
* This opcode is implemented by the {@link SSubCommand} class, which defines its specific execution logic.
@@ -306,8 +300,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic short16 subtraction tasks.
*/
- public static final int S_SUB = 22;
-
+ public static final int S_SUB = 21;
/**
* S_MUL Opcode: Represents the short16 multiplication operation in the virtual machine.
* This opcode is implemented by the {@link SMulCommand} class, which defines its specific execution logic.
@@ -322,8 +315,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic short16 multiplication tasks.
*/
- public static final int S_MUL = 23;
-
+ public static final int S_MUL = 22;
/**
* S_DIV Opcode: Represents the short16 division operation in the virtual machine.
* This opcode is implemented by the {@link SDivCommand} class, which defines its specific execution logic.
@@ -339,8 +331,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic short16 division tasks.
*/
- public static final int S_DIV = 24;
-
+ public static final int S_DIV = 23;
/**
* S_MOD Opcode: Represents the short16 modulus (remainder) operation in the virtual machine.
* This opcode is implemented by the {@link SModCommand} class, which defines its specific execution logic.
@@ -356,8 +347,7 @@ public class VMOpCode {
* This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic short16 modulus (remainder) tasks.
*/
- public static final int S_MOD = 25;
-
+ public static final int S_MOD = 24;
/**
* S_INC Opcode: Represents the short16 increment operation in the virtual machine.
* This opcode is implemented by the {@link SIncCommand} class, which defines its specific execution logic.
@@ -375,8 +365,7 @@ public class VMOpCode {
* This opcode is useful for scenarios where a local variable needs to be incremented, such as counters within loops,
* or for optimizing the modification of variables in tight loops.
*/
- public static final int S_INC = 26;
-
+ public static final int S_INC = 25;
/**
* S_NEG Opcode: Represents the short16 negation operation in the virtual machine.
* This opcode is implemented by the {@link SNegCommand} class, which defines its specific execution logic.
@@ -390,9 +379,10 @@ public class VMOpCode {
*
* This opcode is typically used to negate a short16 value, making it a fundamental operation for arithmetic logic within the virtual machine.
*/
- public static final int S_NEG = 27;
+ public static final int S_NEG = 26;
+ // endregion
- // 1.4 byte8 (31-40)
+ // region 1.4 byte8 (31-40)
/**
* B_ADD Opcode: Represents the byte8 addition operation in the virtual machine.
* This opcode is implemented by the {@link BAddCommand} class, which defines its specific execution logic.
@@ -408,7 +398,6 @@ public class VMOpCode {
* primarily used to handle basic byte8 addition tasks.
*/
public static final int B_ADD = 31;
-
/**
* B_SUB Opcode: Represents the byte8 subtraction operation in the virtual machine.
* This opcode is implemented by the {@link BSubCommand} class, which defines its specific execution logic.
@@ -424,7 +413,6 @@ public class VMOpCode {
* primarily used to handle basic byte8 subtraction tasks.
*/
public static final int B_SUB = 32;
-
/**
* B_MUL Opcode: Represents the byte8 multiplication operation in the virtual machine.
* This opcode is implemented by the {@link BMulCommand} class, which defines its specific execution logic.
@@ -440,7 +428,6 @@ public class VMOpCode {
* primarily used to handle basic byte8 multiplication tasks.
*/
public static final int B_MUL = 33;
-
/**
* B_DIV Opcode: Represents the byte8 division operation in the virtual machine.
* This opcode is implemented by the {@link BDivCommand} class, which defines its specific execution logic.
@@ -457,7 +444,6 @@ public class VMOpCode {
* primarily used to handle basic byte8 division tasks.
*/
public static final int B_DIV = 34;
-
/**
* B_MOD Opcode: Represents the byte8 modulus (remainder) operation in the virtual machine.
* This opcode is implemented by the {@link BModCommand} class, which defines its specific execution logic.
@@ -474,7 +460,6 @@ public class VMOpCode {
* primarily used to handle basic byte8 modulus (remainder) tasks.
*/
public static final int B_MOD = 35;
-
/**
* B_INC Opcode: Represents the byte8 increment operation for a local variable in the virtual machine.
* This opcode is implemented by the {@link BIncCommand} class, which defines its specific execution logic.
@@ -492,8 +477,6 @@ public class VMOpCode {
* This opcode is particularly useful for optimizing scenarios where a local `byte8` variable, such as a counter or loop index, is frequently incremented.
*/
public static final int B_INC = 36;
-
-
/**
* B_NEG Opcode: Represents the byte8 negation operation in the virtual machine.
* This opcode is implemented by the {@link BNegCommand} class, which defines its specific execution logic.
@@ -508,8 +491,9 @@ public class VMOpCode {
* This opcode is typically used to negate a byte8 value, making it a fundamental operation for arithmetic logic within the virtual machine.
*/
public static final int B_NEG = 37;
+ // endregion
- // 1.5 double64 (41-50)
+ // region 1.5 double64 (41-50)
/**
* D_ADD Opcode: Represents the double64 precision floating-point addition operation in the virtual machine.
* This opcode is implemented by the {@link DAddCommand} class, which defines its specific execution logic.
@@ -525,7 +509,6 @@ public class VMOpCode {
* primarily used to handle basic double64 precision floating-point addition tasks.
*/
public static final int D_ADD = 41;
-
/**
* D_SUB Opcode: Represents the double64 precision floating-point subtraction operation in the virtual machine.
* This opcode is implemented by the {@link DSubCommand} class, which defines its specific execution logic.
@@ -541,7 +524,6 @@ public class VMOpCode {
* primarily used to handle basic double64 precision floating-point subtraction tasks.
*/
public static final int D_SUB = 42;
-
/**
* D_MUL Opcode: Represents the double64 precision floating-point multiplication operation in the virtual machine.
* This opcode is implemented by the {@link DMulCommand} class, which defines its specific execution logic.
@@ -557,7 +539,6 @@ public class VMOpCode {
* primarily used to handle basic double64 precision floating-point multiplication tasks.
*/
public static final int D_MUL = 43;
-
/**
* D_DIV Opcode: Represents the double64 precision floating-point division operation in the virtual machine.
* This opcode is implemented by the {@link DDivCommand} class, which defines its specific execution logic.
@@ -574,7 +555,6 @@ public class VMOpCode {
* primarily used to handle basic double64 precision floating-point division tasks.
*/
public static final int D_DIV = 44;
-
/**
* D_MOD Opcode: Represents the double64 precision floating-point modulus (remainder) operation in the virtual machine.
* This opcode is implemented by the {@link DModCommand} class, which defines its specific execution logic.
@@ -591,7 +571,6 @@ public class VMOpCode {
* primarily used to handle basic double64 precision floating-point modulus (remainder) tasks.
*/
public static final int D_MOD = 45;
-
/**
* D_INC Opcode: Represents the double64 increment operation for a local variable in the virtual machine.
* This opcode is implemented by the {@link DIncCommand} class, which defines its specific execution logic.
@@ -609,7 +588,6 @@ public class VMOpCode {
* This opcode is particularly useful for optimizing scenarios where a local `double64` variable, such as a counter or loop index, is frequently incremented.
*/
public static final int D_INC = 46;
-
/**
* D_NEG Opcode: Represents the double64 precision floating-point negation operation in the virtual machine.
* This opcode is implemented by the {@link DNegCommand} class, which defines its specific execution logic.
@@ -624,8 +602,9 @@ public class VMOpCode {
* This opcode is typically used to negate a double64 precision floating-point value, making it a fundamental operation for double64 precision arithmetic logic within the virtual machine.
*/
public static final int D_NEG = 47;
+ // endregion
- // 1.6 float32 (51-60)
+ // region 1.6 float32 (51-60)
/**
* F_ADD Opcode: Represents the float32 addition operation in the virtual machine.
* This opcode is implemented by the {@link FAddCommand} class, which defines its specific execution logic.
@@ -720,7 +699,6 @@ public class VMOpCode {
* This opcode is particularly useful for optimizing scenarios where a local `float32` variable, such as a counter or loop index, is frequently incremented.
*/
public static final int F_INC = 56;
-
/**
* F_NEG Opcode: Represents the float32 negation operation in the virtual machine.
* This opcode is implemented by the {@link FNegCommand} class, which defines its specific execution logic.
@@ -735,7 +713,10 @@ public class VMOpCode {
* This opcode is typically used to negate a float32 value, making it a fundamental operation for float32 arithmetic logic within the virtual machine.
*/
public static final int F_NEG = 57;
+ // endregion
+ // endregion
+ // region 2. Type Conversion Operation
/**
* I2L Opcode: Represents the type conversion operation from int32 to long64 in the virtual machine.
* This opcode is implemented by the {@link I2LCommand} class, which defines its specific execution logic.
@@ -750,7 +731,6 @@ public class VMOpCode {
* This opcode is commonly used to widen an int32 value to a long64 type to accommodate larger numeric ranges.
*/
public static final int I2L = 61;
-
/**
* I2S Opcode: Represents the type conversion operation from int32 to short16 in the virtual machine.
* This opcode is implemented by the {@link I2SCommand} class, which defines its specific execution logic.
@@ -765,7 +745,6 @@ public class VMOpCode {
* This opcode is typically used to narrow an int32 value to a short16 type when a smaller data representation is needed.
*/
public static final int I2S = 62;
-
/**
* I2B Opcode: Represents the type conversion operation from int32 to byte8 in the virtual machine.
* This opcode is implemented by the {@link I2BCommand} class, which defines its specific execution logic.
@@ -780,7 +759,6 @@ public class VMOpCode {
* This opcode is used to narrow an int32 value to a byte8 type, suitable when a smaller numeric type is required.
*/
public static final int I2B = 63;
-
/**
* I2D Opcode: Represents the type conversion operation from int32 to double64 in the virtual machine.
* This opcode is implemented by the {@link I2DCommand} class, which defines its specific execution logic.
@@ -795,7 +773,6 @@ public class VMOpCode {
* This opcode is used to widen an int32 value to a double64 type, providing high-precision floating-point calculations.
*/
public static final int I2D = 64;
-
/**
* I2F Opcode: Represents the type conversion operation from int32 to float32 in the virtual machine.
* This opcode is implemented by the {@link I2FCommand} class, which defines its specific execution logic.
@@ -810,7 +787,6 @@ public class VMOpCode {
* This opcode is used to convert an int32 value to a float32 type when floating-point arithmetic is required.
*/
public static final int I2F = 65;
-
/**
* L2I Opcode: Represents the type conversion operation from long64 to int32 in the virtual machine.
* This opcode is implemented by the {@link L2ICommand} class, which defines its specific execution logic.
@@ -825,7 +801,6 @@ public class VMOpCode {
* This opcode is typically used to narrow a long64 value to an int32 type for further integer operations.
*/
public static final int L2I = 66;
-
/**
* L2D Opcode: Represents the type conversion operation from long64 to double64 in the virtual machine.
* This opcode is implemented by the {@link L2DCommand} class, which defines its specific execution logic.
@@ -975,11 +950,10 @@ public class VMOpCode {
* This opcode is used to widen a byte8 value to an int32 type to ensure compatibility with integer-based operations.
*/
public static final int B2I = 76;
+ // endregion
-
-
- // 2. Bitwise Operations (81–90)
- // 2.1 int32 (81-85)
+ // region 2. Bitwise Operations (81–90)
+ // region 2.1 int32 (81-85)
/**
* I_AND Opcode: Represents the int32 bitwise AND operation in the virtual machine.
* This opcode is implemented by the {@link IAndCommand} class, which defines its specific execution logic.
@@ -1039,7 +1013,8 @@ public class VMOpCode {
*/
public static final int I_XOR = 83;
- // 2.2 Long64 (86-90)
+ // endregion
+ // region 2.2 Long64 (86-90)
/**
* L_AND Opcode: Represents the long64 bitwise AND operation in the virtual machine.
* This opcode is implemented by the {@link LAndCommand} class, which defines its specific execution logic.
@@ -1100,8 +1075,10 @@ public class VMOpCode {
public static final int L_XOR = 88;
- // 3. Control Flow Operations (91–110)
- // 3.1 JUMP (91-91)
+ // endregion
+ // endregion
+ // region 3. Control Flow Operations (91–110)
+ // region 3.1 JUMP (91-91)
/**
* JUMP Opcode: Represents an unconditional jump to a target instruction address.
* This opcode is implemented by the {@link JumpCommand} class, which defines its specific execution logic.
@@ -1121,7 +1098,9 @@ public class VMOpCode {
*
*/
public static final int JUMP = 91;
- // 3.2 int32 (92-97)
+
+ // endregion
+ // region 3.2 int32 (92-97)
/**
* IC_E Opcode: Represents a conditional jump based on int32 equality.
* This opcode is implemented by the {@link ICECommand} class, which defines its specific execution logic.
@@ -1248,7 +1227,9 @@ public class VMOpCode {
*
*/
public static final int IC_LE = 97;
- // 3.3 long64 (98-103)
+
+ // endregion
+ // region 3.3 long64 (98-103)
/**
* LC_E Opcode: Represents a conditional jump based on long64 equality.
* This opcode is implemented by the {@link ICECommand} class, which defines its specific execution logic.
@@ -1376,8 +1357,10 @@ public class VMOpCode {
*/
public static final int LC_LE = 103;
- // 4. Stack Operations (111–150)
- // 4.1 PUSH (111-120)
+ // endregion
+ // endregion
+ // region 4. Stack Operations (111–150)
+ // region 4.1 PUSH (111-120)
/**
* I_PUSH Opcode: Represents a stack operation that pushes an int32 value onto the operand stack.
* This opcode is implemented by the {@link IPushCommand} class, which defines its specific execution logic.
@@ -1492,6 +1475,8 @@ public class VMOpCode {
*
*/
public static final int F_PUSH = 116;
+ // endregion
+ // region 4.2 POP (121-125)
/**
* I_POP Opcode: Represents a stack operation that removes the top element from the operand stack.
* This opcode is implemented by the {@link PopCommand} class, which defines its specific execution logic.
@@ -1510,8 +1495,9 @@ public class VMOpCode {
* Ensuring stack balance during function calls or control flow transitions.
*
*/
- // 4.2 POP (121-125)
public static final int POP = 121;
+ // endregion
+ // region 4.3 DUP (126-130)
/**
* DUP Opcode: Represents a stack operation that duplicates the top element of the operand stack.
* This opcode is implemented by the {@link DupCommand} class, which defines its specific execution logic.
@@ -1530,8 +1516,11 @@ public class VMOpCode {
* Managing stack balance when performing operations that require repeated access to the same data.
*
*/
- // 4.3 DUP (126-130)
+
public static final int DUP = 126;
+ // endregion
+
+ // region 4.4 SWAP (131-135)
/**
* SWAP Opcode: Represents a stack operation that swaps the top two values of the operand stack.
* This opcode is implemented by the {@link SwapCommand} class, which defines its specific execution logic.
@@ -1551,10 +1540,11 @@ public class VMOpCode {
* Ensuring proper operand placement for later instructions that depend on the order of stack elements.
*
*/
- // 4.4 SWAP (131-135)
public static final int SWAP = 131;
+ // endregion
- // 5. Memory Operations (151–)
+ // endregion
+ // region 5. Memory Operations (151–166)
/**
* I_STORE Opcode: Represents a store operation that saves an int32 value from the operand stack into the local variable store.
*
@@ -1576,8 +1566,6 @@ public class VMOpCode {
*
*/
public static final int I_STORE = 151;
-
-
/**
* 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.
@@ -1598,8 +1586,6 @@ public class VMOpCode {
*
*/
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.
@@ -1620,8 +1606,6 @@ public class VMOpCode {
*
*/
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.
@@ -1642,8 +1626,6 @@ public class VMOpCode {
*
*/
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.
@@ -1664,7 +1646,6 @@ public class VMOpCode {
*
*/
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.
@@ -1685,8 +1666,6 @@ public class VMOpCode {
*
*/
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.
@@ -1828,6 +1807,8 @@ public class VMOpCode {
*
*/
public static final int MOV = 171;
+ // endregion
+ // region 6. Function Call
/**
* CALL Opcode: Represents a function or subroutine call operation that transfers control to a specified function address.
* This opcode is implemented by the {@link CallCommand} class, which defines its specific execution logic.
@@ -1885,9 +1866,7 @@ public class VMOpCode {
*
*/
public static final int HALT = 255;
-
-
- // VI. Function Operations (50–59)
+ // endregion
/**
* Default constructor for creating an instance of VMOpCode.