From f6780194a51e36c38f4baebc9d01f157aa61ef4a Mon Sep 17 00:00:00 2001 From: zhangxun <1958638841@qq.com> Date: Thu, 10 Jul 2025 16:19:27 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85=20short16=20?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=8C=87=E4=BB=A4=E7=9A=84=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jcnc/snow/vm/engine/VMOpCode.java | 71 +++++++++++++++++-- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java index 46430d8..f92c83d 100644 --- a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java +++ b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java @@ -2057,15 +2057,75 @@ public class VMOpCode { // endregion Byte8 // region Short16 (0x00C5-0xC9) - + /** + * S2B Opcode: Represents the type conversion operation from short16 to byte8 in the virtual machine. + *

This opcode is implemented by the {@link S2BCommand} 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 a byte8 value (this may involve truncation).
  4. + *
  5. Push the converted byte8 value back onto the operand stack for subsequent operations.
  6. + *
+ * + *

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

+ */ public static final int S2B = 0x00C5; - + /** + * 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 commonly used to widen a short16 value to an int32 type to accommodate larger numeric ranges.

+ */ public static final int S2I = 0x00C6; - + /** + * S2L Opcode: Represents the type conversion operation from short16 to long64 in the virtual machine. + *

This opcode is implemented by the {@link S2LCommand} 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 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 a short16 value to a long64 type to accommodate larger numeric ranges.

+ */ public static final int S2L = 0x00C7; - + /** + * S2F Opcode: Represents the type conversion operation from short16 to float32 in the virtual machine. + *

This opcode is implemented by the {@link S2FCommand} 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 a float32 value.
  4. + *
  5. Push the converted float32 value back onto the operand stack for subsequent operations.
  6. + *
+ * + *

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

+ */ public static final int S2F = 0x00C8; - + /** + * S2D Opcode: Represents the type conversion operation from short16 to double64 in the virtual machine. + *

This opcode is implemented by the {@link S2DCommand} 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 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 short16 value to a double64 type, providing high-precision floating-point calculations.

+ */ public static final int S2D = 0x00C9; // endregion Short16 @@ -2099,7 +2159,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 = 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.