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 c53f511..8b634ca 100644 --- a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java +++ b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java @@ -2043,34 +2043,33 @@ public class VMOpCode { // endregion // region Type Conversion (0x00C0-0x00DF) - /** - * I2L Opcode: Represents the type conversion operation from int32 to long64 in the virtual machine. - *

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

- * - *

Execution Steps:

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

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

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

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

- * - *

Execution Steps:

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

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

- */ - public static final int I2S = 0x00C1; + // region Byte8 (0x00C0-0xC4) + + public static final int B2S = 0x00C0; + + public static final int B2I = 0x00C1; + + public static final int B2L = 0x00C2; + + public static final int B2F = 0x00C3; + + public static final int B2D = 0x00C4; + // endregion Byte8 + + // region Short16 (0x00C5-0xC9) + + public static final int S2B = 0x00C5; + + public static final int S2I = 0x00C6; + + public static final int S2L = 0x00C7; + + public static final int S2F = 0x00C8; + + public static final int S2D = 0x00C9; + // endregion Short16 + + // region Int32 (0x00CA-0xCE) /** * 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.

@@ -2084,21 +2083,37 @@ 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 = 0x00C2; + public static final int I2B = 0x00CA; + /** - * 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.

+ * I2S Opcode: Represents the type conversion operation from int32 to short16 in the virtual machine. + *

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

* *

Execution Steps:

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

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

+ *

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 I2D = 0x00C3; + public static final int I2S = 0x00CB; + + /** + * I2L Opcode: Represents the type conversion operation from int32 to long64 in the virtual machine. + *

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

+ * + *

Execution Steps:

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

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

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

@@ -2112,7 +2127,29 @@ 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 = 0x00C4; + public static final int I2F = 0x00CD; + /** + * I2D Opcode: Represents the type conversion operation from int32 to double64 in the virtual machine. + *

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

+ * + *

Execution Steps:

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

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

+ */ + public static final int I2D = 0x00CE; + // endregion Int32 + + // region Long64 (0x00CF-0xD3) + + public static final int L2B = 0x00CF; + + public static final int L2S = 0x00D0; + /** * 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.

@@ -2126,21 +2163,7 @@ 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 = 0x00C5; - /** - * L2D Opcode: Represents the type conversion operation from long64 to double64 in the virtual machine. - *

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

- * - *

Execution Steps:

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

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

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

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

@@ -2154,7 +2177,29 @@ public class VMOpCode { * *

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

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

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

+ * + *

Execution Steps:

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

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

+ */ + public static final int L2D = 0x00D3; + // endregion Long64 + + // region Float32 (0x00D4-0xD8) + + public static final int F2B = 0x00D4; + + public static final int F2S = 0x00D5; + /** * F2I Opcode: Represents the type conversion operation from float32 to int32 in the virtual machine. *

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

@@ -2168,7 +2213,7 @@ public class VMOpCode { * *

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

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

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

@@ -2182,7 +2227,7 @@ public class VMOpCode { * *

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

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

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

@@ -2196,7 +2241,15 @@ public class VMOpCode { * *

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

*/ - public static final int F2D = 0x00CA; + public static final int F2D = 0x00D8; + // endregion Float32 + + // region Double64 (0x00D9-0xDD) + + public static final int D2B = 0x00D9; + + public static final int D2S = 0x00DA; + /** * D2I Opcode: Represents the type conversion operation from double64 to int32 in the virtual machine. *

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

@@ -2210,7 +2263,7 @@ public class VMOpCode { * *

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

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

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

@@ -2224,7 +2277,7 @@ public class VMOpCode { * *

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

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

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

@@ -2238,36 +2291,9 @@ public class VMOpCode { * *

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

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

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

- * - *

Execution Steps:

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

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

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

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

- * - *

Execution Steps:

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

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

- */ - public static final int B2I = 0x00CF; - // endregion + public static final int D2F = 0x00DD; + // endregion Double64 + // endregion Conversion // region Stack Control (0x0100-0x01FF) /** diff --git a/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java b/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java index a5af00b..4054a11 100644 --- a/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java +++ b/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java @@ -207,26 +207,41 @@ public class CommandFactory { // endregion // region Type Conversion (0x00C0-0x00DF) - COMMANDS[VMOpCode.I2L] = new I2LCommand(); - COMMANDS[VMOpCode.I2S] = new I2SCommand(); + COMMANDS[VMOpCode.B2S] = new B2SCommand(); + COMMANDS[VMOpCode.B2I] = new B2ICommand(); + COMMANDS[VMOpCode.B2L] = new B2LCommand(); + COMMANDS[VMOpCode.B2F] = new B2FCommand(); + COMMANDS[VMOpCode.B2D] = new B2DCommand(); + + COMMANDS[VMOpCode.S2B] = new S2BCommand(); + COMMANDS[VMOpCode.S2I] = new S2ICommand(); + COMMANDS[VMOpCode.S2L] = new S2LCommand(); + COMMANDS[VMOpCode.S2F] = new S2FCommand(); + COMMANDS[VMOpCode.S2D] = new S2DCommand(); + COMMANDS[VMOpCode.I2B] = new I2BCommand(); - COMMANDS[VMOpCode.I2D] = new I2DCommand(); + COMMANDS[VMOpCode.I2S] = new I2SCommand(); + COMMANDS[VMOpCode.I2L] = new I2LCommand(); COMMANDS[VMOpCode.I2F] = new I2FCommand(); + COMMANDS[VMOpCode.I2D] = new I2DCommand(); + COMMANDS[VMOpCode.L2B] = new L2BCommand(); + COMMANDS[VMOpCode.L2S] = new L2SCommand(); COMMANDS[VMOpCode.L2I] = new L2ICommand(); - COMMANDS[VMOpCode.L2D] = new L2DCommand(); COMMANDS[VMOpCode.L2F] = new L2FCommand(); + COMMANDS[VMOpCode.L2D] = new L2DCommand(); + COMMANDS[VMOpCode.F2B] = new F2BCommand(); + COMMANDS[VMOpCode.F2S] = new F2SCommand(); COMMANDS[VMOpCode.F2I] = new F2ICommand(); COMMANDS[VMOpCode.F2L] = new F2LCommand(); COMMANDS[VMOpCode.F2D] = new F2DCommand(); + COMMANDS[VMOpCode.D2B] = new D2BCommand(); + COMMANDS[VMOpCode.D2S] = new D2SCommand(); COMMANDS[VMOpCode.D2I] = new D2ICommand(); COMMANDS[VMOpCode.D2L] = new D2LCommand(); COMMANDS[VMOpCode.D2F] = new D2FCommand(); - - COMMANDS[VMOpCode.S2I] = new S2ICommand(); - COMMANDS[VMOpCode.B2I] = new B2ICommand(); // endregion // region Stack Control (0x0100-0x01FF)