From b05fff45d4db87897e9a22094b36f9768d666c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Fri, 6 Sep 2024 18:03:15 +0800 Subject: [PATCH 01/12] add opcodes.md --- docs/n3/reference/Opcodes.md | 783 +++++++++++++++++++++++++++++++++++ docs/n3/reference/opcode.css | 31 ++ 2 files changed, 814 insertions(+) create mode 100644 docs/n3/reference/Opcodes.md create mode 100644 docs/n3/reference/opcode.css diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md new file mode 100644 index 0000000..0c9ef84 --- /dev/null +++ b/docs/n3/reference/Opcodes.md @@ -0,0 +1,783 @@ +--- +sidebar_label: 'NeoVM OpCodes' +--- + +# Neo Virtual Machine OpCodes + +Use this handy table to skip ahead to the [opcode reference](#opcodes). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
00010203040508090A0B0C0D0E0F
101112131415161718191A1B1C1D1E1F
202122232425262728292A2B2C2D2E2F
303132333435363738393A3B3C3D3E3F
404143454648494A4B4D4E
505152535455565758595A5B5C5D5E5F
606162636465666768696A6B6C6D6E6F
707172737475767778797A7B7C7D7E7F
808182838485868788898B8C8D8E
909192939798999A9B9C9D9E9F
A0A1A2A3A4A5A6A8A9AAABAC
B1B3B4B5B6B7B8B9BABBBEBF
C0C1C2C3C4C5C6C8CACBCCCDCECF
D0D1D2D3D4D8D9DB
E0E1
+ +## OverView + +This OpCode collection defines a set of instructions for handling stack operations, compound-type operations, bitwise +logic, arithmetic calculations, and more. + +- **Constants** + +These opcodes are used to push constant values onto the stack. Included are instructions for pushing integers of +different sizes (e.g., signed integers from 1 byte to 32 bytes) onto the stack (PUSHINT8 through PUSHINT256), as well as +instructions for pushing Boolean values true (PUSHT) and false (PUSHF). Also included are opcodes for pushing pointers +(PUSHA), nulls (PUSHNULL), data blocks (PUSHDATA1 through PUSHDATA4), and fixed values (PUSHM1 through PUSH16) onto the +stack. + +Translated with DeepL.com (free version) + +- **Flow Control** +Flow control opcodes are used to control the flow of program execution. These instructions are typically used for +operations such as conditional jumps, loops, and method calls to implement complex logic control. + +- **Stack** +Stack opcodes are used to manipulate data on the stack and support push, pop, duplicate and swap operations. They play +an important role in data manipulation and management to ensure that data can be efficiently manipulated and transferred +as expected. + +- **Slot** +The Slot opcode is used to manage the operation of local variable slots. These instructions allow data to be stored into +or loaded from specific slots to support the management of local variables and parameters. + +- **Splice** +The splice opcode is used to handle splice, split, and extract operations on byte arrays and strings. These instructions +can be used to merge multiple chunks of data or to extract portions of existing data. + +- **Bitwise Logic** +Bitwise logical opcodes are used to perform bitwise operations (e.g., AND, OR, XOR, NOT, etc.) that are typically used +in low-level data processing, such as encryption and compression algorithms. + +- **Arithmetic** +Arithmetic opcodes are used to perform basic arithmetic operations (such as addition, subtraction, multiplication, +division, etc.). These operations are very useful in implementing data calculations and numerical processing. + +- **Compound-Type** +Complex type opcodes are used to manipulate complex data types such as arrays, structures, and other custom types. These +instructions are used to create, modify and destroy complex data types. + +- **Types** +Type opcodes are used to handle and manipulate the conversion and checking of data types. These instructions are used to +determine the type of data or to convert one type to another. + +- **Extensions** +Advanced operations with special effects. + +## OpCodes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
No.NameStack InputStack OutputExpressionNotes
00PUSHINT8- + + + + + + + +
a
+
- + Pushes a 1-byte signed integer onto the stack. +
01PUSHINT16- + + + + + + + +
a
+
- + Pushes a 2-byte signed integer onto the stack. +
02PUSHINT32- + + + + + + + +
a
+
- + Pushes a 4-byte signed integer onto the stack. +
03PUSHINT64- + + + + + + + +
a
+
- + Pushes a 8-byte signed integer onto the stack. +
04PUSHINT128- + + + + + + + +
a
+
+ - + + Pushes a 16-byte signed integer onto the stack. +
05PUSHINT256- + + + + + + + +
a
+
- + Pushes a 32-byte signed integer onto the stack. +
08PUSHT- + + + + + + + +
true
+
+ - + + Pushes the boolean value true onto the stack. +
09PUSHF- + + + + + + + +
false
+
- + Pushes the boolean value false onto the stack. +
0APUSHA- + + + + + + + +
Pointer
+
- + Converts the 4-bytes offset to an Pointer, and pushes it onto the stack.. +
0BPUSHNULL- + + + + + + + +
null
+
- + The item null is pushed onto the stack. +
Unfinished to be continued...
99SIGN + + + + + + + +
a
+
+ + + + + + + +
a.Sign
+
+ a.Sign + + Puts the sign of top stack item on top of the main stack. If value is negative, put -1; if positive, put 1; if value is zero, put 0. +
9AABS + + + + + + + +
a
+
+ + + + + + + +
abs(a)
+
+ abs(a) + + The input is made positive. +
9BNEGATE + + + + + + + +
a
+
+ + + + + + + +
-a
+
+ -a + + The sign of the input is flipped. +
9CINC + + + + + + + +
a
+
+ + + + + + + +
a+1
+
+ a+1 + + 1 is added to the input. +
9DDEC + + + + + + + +
a
+
+ + + + + + + +
a-1
+
+ a-1 + + 1 is subtracted from the input. +
9EADD + + + + + + + + +
ba
+
+ + + + + + + +
a+b
+
+ a+b + + a is added to b. +
9FSUB + + + + + + + + +
ba
+
+ + + + + + + +
a-b
+
+ a-b + + b is subtracted from a. +
Unfinished to be continued...
+ diff --git a/docs/n3/reference/opcode.css b/docs/n3/reference/opcode.css new file mode 100644 index 0000000..32d8ddc --- /dev/null +++ b/docs/n3/reference/opcode.css @@ -0,0 +1,31 @@ +.stack>tbody>tr>td:last-child { + border-right: 0; +} + +.stack.table-bordered { + border-right: 0; +} + +.table.opcode{ + font-size: 70%; + width: auto; +} +.table.opcode td{ + padding: .2rem; + border-right-width: 1px; + height: 20px; + width: 30px; +} +.table .stack td{ + padding: .4rem; + border: 1px solid rgba(128, 128, 128, .5); +} +a.anchor { + display: block; + height: 5rem; + margin-top: -5rem; + visibility: hidden; +} +.table{ + table-layout: fixed; +} \ No newline at end of file From d323c1529da1fd76b2e600089fb61d57d5f37c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Mon, 9 Sep 2024 17:56:16 +0800 Subject: [PATCH 02/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 903 +++++++++++++++++++++++++++++++++++ 1 file changed, 903 insertions(+) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index 0c9ef84..428531f 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -560,6 +560,909 @@ Advanced operations with special effects. The item null is pushed onto the stack. + + 0C + PUSHDATA1 + - + + + + + + + + +
a
+ + - + + The next byte contains the number of bytes to be pushed onto the stack. + + + + 0D + PUSHDATA2 + - + + + + + + + + +
a
+ + - + + The next two bytes contain the number of bytes to be pushed onto the stack. + + + + 0E + PUSHDATA4 + - + + + + + + + + +
a
+ + - + + The next four bytes contain the number of bytes to be pushed onto the stack. + + + + 0F + PUSHM1 + - + + + + + + + + +
-1
+ + - + + The number -1 is pushed onto the stack. + + + + 10 + PUSH0 + - + + + + + + + + +
0
+ + - + + The number 0 is pushed onto the stack. + + + + 11 + PUSH1 + - + + + + + + + + +
1
+ + - + + The number 1 is pushed onto the stack. + + + + 12 + PUSH2 + - + + + + + + + + +
2
+ + - + + The number 2 is pushed onto the stack. + + + + 13 + PUSH3 + - + + + + + + + + +
3
+ + - + + The number 3 is pushed onto the stack. + + + + 14 + PUSH4 + - + + + + + + + + +
4
+ + - + + The number 4 is pushed onto the stack. + + + + 15 + PUSH5 + - + + + + + + + + +
5
+ + - + + The number 5 is pushed onto the stack. + + + + 16 + PUSH6 + - + + + + + + + + +
6
+ + - + + The number 6 is pushed onto the stack. + + + + 17 + PUSH7 + - + + + + + + + + +
7
+ + - + + The number 7 is pushed onto the stack. + + + + 18 + PUSH8 + - + + + + + + + + +
8
+ + - + + The number 8 is pushed onto the stack. + + + + 19 + PUSH9 + - + + + + + + + + +
9
+ + - + + The number 9 is pushed onto the stack. + + + + 1A + PUSH10 + - + + + + + + + + +
10
+ + - + + The number 10 is pushed onto the stack. + + + + 1B + PUSH11 + - + + + + + + + + +
11
+ + - + + The number 11 is pushed onto the stack. + + + + 1C + PUSH12 + - + + + + + + + + +
12
+ + - + + The number 12 is pushed onto the stack. + + + + 1D + PUSH13 + - + + + + + + + + +
13
+ + - + + The number 13 is pushed onto the stack. + + + + 1E + PUSH14 + - + + + + + + + + +
14
+ + - + + The number 14 is pushed onto the stack. + + + + 1F + PUSH15 + - + + + + + + + + +
15
+ + - + + The number 15 is pushed onto the stack. + + + + 20 + PUSH16 + - + + + + + + + + +
16
+ + - + + The number 16 is pushed onto the stack. + + + + 21 + NOP + - + - + - + + The NOP operation does nothing. It is intended to fill in space if opcodes are patched. + + + + 22 + JMP + - + - + - + + Unconditionally transfers control to a target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 23 + JMP + - + - + - + + Unconditionally transfers control to a target instruction. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 24 + JMPIF + + + + + + + + +
a
+ + - + - + + Transfers control to a target instruction if the value is true, not null, or non-zero. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 25 + JMPIF_L + + + + + + + + +
a
+ + - + - + + Transfers control to a target instruction if the value is true, not null, or non-zero. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 26 + JMPIFNOT + + + + + + + + +
a
+ + - + - + + Transfers control to a target instruction if the value is false, a null reference, or zero. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 27 + JMPIFNOT_L + + + + + + + + +
a
+ + - + - + + Transfers control to a target instruction if the value is false, a null reference, or zero. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 28 + JMPEQ + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if two values are equal. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 29 + JMPEQ_L + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if two values are equal. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 2A + JMPNE + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction when two values are not equal. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 2B + JMPNE_L + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction when two values are not equal. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 2C + JMPGT + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if the first value is greater than the second value. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 2D + JMPGT_L + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if the first value is greater than the second value. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 2E + JMPGE + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if the first value is greater than or equal to the second value. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 2F + JMPGE_L + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if the first value is greater than or equal to the second value. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 30 + JMPLT + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if the first value is less than the second value. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 31 + JMPLT_L + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if the first value is less than the second value. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 32 + JMPLE + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if the first value is less than or equal to the second value. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 33 + JMPLE_L + + + + + + + + + +
ba
+ + - + - + + Transfers control to a target instruction if the first value is less than or equal to the second value. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 34 + CALL + - + - + - + + Calls the function at the target address which is represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 35 + CALL_L + - + - + - + + Calls the function at the target address which is represented as a 4-bytes signed offset from the beginning of the current instruction. + + + + 36 + CALLA + - + - + - + + Pop the address of a function from the stack, and call the function. + + + + 37 + CALLT + - + - + - + + Calls the function which is described by the token. + + + + 38 + ABORT + - + - + - + + It turns the vm state to FAULT immediately, and cannot be caught. + + + + 39 + ASSERT + + + + + + + + +
a
+ + - + - + + Pop the top value of the stack. If it's false, exit vm execution and set vm state to FAULT. + + + + 3A + THROW + + + + + + + + +
a
+ + - + - + + Pop the top value of the stack, and throw it. + + + + 3B + TRY + - + - + - + + TRY CatchOffset(sbyte) FinallyOffset(sbyte). If there's no catch body, set CatchOffset 0. If there's no finally body, set FinallyOffset 0. + + + + 3C + TRY_L + - + - + - + + TRY_L CatchOffset(int) FinallyOffset(int). If there's no catch body, set CatchOffset 0. If there's no finally body, set FinallyOffset 0. + + + + 3D + ENDTRY + - + - + - + + Ensures that the appropriate surrounding finally blocks are executed. And then unconditionally transfers control to the specific target instruction, represented as a 1-byte signed offset from the beginning of the current instruction. + + + + 3E + ENDTRY_L + - + - + - + + Ensures that the appropriate surrounding finally blocks are executed. And then unconditionally transfers control to the specific target instruction, represented as a 4-byte signed offset from the beginning of the current instruction. + + + + 3F + ENDFINALLY + - + - + - + + End finally, If no exception happen or be catched, vm will jump to the target instruction of ENDTRY/ENDTRY_L. Otherwise, vm will rethrow the exception to upper layer. + + + + 40 + RET + - + - + - + + Returns from the current method. + + + + 41 + SYSCALL + - + - + - + + Calls to an interop service. + + Unfinished to be continued... From 593237cc7c40c8f684718e8d68d803087b4e2a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Mon, 9 Sep 2024 17:57:01 +0800 Subject: [PATCH 03/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 2513 +++++++++++++++++++++++++++++++++- 1 file changed, 2476 insertions(+), 37 deletions(-) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index 428531f..61c050b 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -1464,15 +1464,2211 @@ Advanced operations with special effects. - Unfinished to be continued... + 43 + DEPTH + - + + + + + + + + +
a
+ + - + + Puts the number of stack items onto the stack. + + + + 45 + DROP + + + + + + + + + + +
abc
+ + + + + + + + + + +
ab
+ + - + + Removes the top stack item. + + + + 46 + NIP + + + + + + + + + + +
abc
+ + + + + + + + + + +
ac
+ + - + + Removes the second-to-top stack item. + + + + 48 + XDROP + + + + + + + + +
-
+ + - + - + + The item n back in the main stack is removed. + + + + 49 + CLEAR + + + + + + + + +
-
+ + - + - + + Clear the stack + + + + 4A + DUP + + + + + + + + + + +
abc
+ + + + + + + + + + + + +
abcc
+ + - + + Duplicates the top stack item. + + + + 4B + OVER + + + + + + + + + + +
abc
+ + + + + + + + + + + + +
abcb
+ + - + + Copies the second-to-top stack item to the top. + + + + 4D + PICK + + + + + + + + + + +
anb
+ + + + + + + + + + + + +
anbn
+ + - + + The item n back in the stack is copied to the top. + + + + 4E + TUCK + + + + + + + + + + +
abc
+ + + + + + + + + + + + +
abcc
+ + - + + The item at the top of the stack is copied and inserted before the second-to-top item. + + + + 50 + SWAP + + + + + + + + + +
ab
+ + + + + + + + + + +
ba
+ + - + + The top two items on the stack are swapped. + + + + 51 + ROT + + + + + + + + + + +
abc
+ + + + + + + + + + + +
bca
+ + - + + The top three items on the stack are rotated to the left. + + + + 52 + ROLL + + + + + + + + + + +
anc
+ + + + + + + + + + + +
acn
+ + - + + The item n back in the stack is moved to the top. + + + + 53 + REVERSE3 + + + + + + + + + + +
abc
+ + + + + + + + + + + +
cba
+ + - + + Reverse the order of the top 3 items on the stack. + + + + 54 + REVERSE4 + + + + + + + + + + + +
abcd
+ + + + + + + + + + + + +
dcba
+ + - + + Reverse the order of the top 4 items on the stack. + + + + 54 + REVERSE4 + + + + + + + + + + +
nba
+ + + + + + + + + + + +
abn
+ + - + + Pop the number N on the stack, and reverse the order of the top N items on the stack. + + + + 56 + INITSSLOT + - + - + - + + Initialize the static field list for the current execution context. + + + + 57 + INITSLOT + - + - + - + + Initialize the argument slot and the local variable list for the current execution context. + + + + 58 + LDSFLD0 + - + + + + + + + + +
a
+ + - + + Loads the static field at index 0 onto the evaluation stack. + + + + 59 + LDSFLD1 + - + + + + + + + + +
a
+ + - + + Loads the static field at index 1 onto the evaluation stack. + + + + 5A + LDSFLD2 + - + + + + + + + + +
a
+ + - + + Loads the static field at index 2 onto the evaluation stack. + + + + 5B + LDSFLD3 + - + + + + + + + + +
a
+ + - + + Loads the static field at index 3 onto the evaluation stack. + + + + 5C + LDSFLD4 + - + + + + + + + + +
a
+ + - + + Loads the static field at index 4 onto the evaluation stack. + + + + 5D + LDSFLD5 + - + + + + + + + + +
a
+ + - + + Loads the static field at index 5 onto the evaluation stack. + + + + 5E + LDSFLD6 + - + + + + + + + + +
a
+ + - + + Loads the static field at index 6 onto the evaluation stack. + + + + 5F + LDSFLD + - + + + + + + + + +
a
+ + - + + Loads the static field at a specified index onto the evaluation stack. The index is represented as a 1-byte unsigned integer. + + + + 60 + STSFLD0 + - + + + + + + + + + +
-a
+ + + + + + + + + +
-
+ + + Stores the value on top of the evaluation stack in the static field list at index 0. + + + + 61 + STSFLD1 + - + + + + + + + + + + +
-a-
+ + + + + + + + + + +
--
+ + + Stores the value on top of the evaluation stack in the static field list at index 1. + + + + 62 + STSFLD2 + - + + + + + + + + + + +
-a-
+ + + + + + + + + + +
--
+ + + Stores the value on top of the evaluation stack in the static field list at index 2. + + + + 63 + STSFLD3 + - + + + + + + + + + + +
-a-
+ + + + + + + + + + +
--
+ + + Stores the value on top of the evaluation stack in the static field list at index 0. + + + + 64 + STSFLD4 + - + + + + + + + + + + +
-a-
+ + + + + + + + + + +
--
+ + + Stores the value on top of the evaluation stack in the static field list at index 4. + + + + 65 + STSFLD5 + - + + + + + + + + + + +
-a-
+ + + + + + + + + + +
--
+ + + Stores the value on top of the evaluation stack in the static field list at index 5. + + + + 66 + STSFLD6 + - + + + + + + + + + + +
-a-
+ + + + + + + + + + +
--
+ + + Stores the value on top of the evaluation stack in the static field list at index 6. + + + + 67 + STSFLD + - + + + + + + + + + + +
-a-
+ + + + + + + + + + +
--
+ + + Stores the value on top of the evaluation stack in the static field list at a specified index. The index is represented as a 1-byte unsigned integer. + + + + 68 + LDLOC0 + - + - + + + + + + + + +
a
+ + + Loads the local variable at index 0 onto the evaluation stack. + + + + 69 + LDLOC1 + - + - + + + + + + + + +
a
+ + + Loads the local variable at index 1 onto the evaluation stack. + + + + 6A + LDLOC2 + - + - + + + + + + + + +
a
+ + + Loads the local variable at index 2 onto the evaluation stack. + + + + 6B + LDLOC3 + - + - + + + + + + + + +
a
+ + + Loads the local variable at index 3 onto the evaluation stack. + + + + 6C + LDLOC4 + - + - + + + + + + + + +
a
+ + + Loads the local variable at index 4 onto the evaluation stack. + + + + 6D + LDLOC5 + - + - + + + + + + + + +
a
+ + + Loads the local variable at index 5 onto the evaluation stack. + + + + 6E + LDLOC6 + - + - + + + + + + + + +
a
+ + + Loads the local variable at index 7 onto the evaluation stack. + + + + 6F + LDLOC + - + - + + + + + + + + +
a
+ + + Loads the local variable at a specified index onto the evaluation stack. The index is represented as a 1-byte unsigned integer. + + + + 70 + STLOC0 + - + + + + + + + + +
a
+ + - + + Stores the value on top of the evaluation stack in the local variable list at index 0. + + + + 71 + STLOC1 + - + + + + + + + + + + +
-a-
+ + - + + Stores the value on top of the evaluation stack in the local variable list at index 1. + + + + 72 + STLOC2 + - + + + + + + + + + + +
-a-
+ + - + + Stores the value on top of the evaluation stack in the local variable list at index 2. + + + + 73 + STLOC3 + - + + + + + + + + + + +
-a-
+ + - + + Stores the value on top of the evaluation stack in the local variable list at index 3. + + + + 74 + STLOC4 + - + + + + + + + + + + +
-a-
+ + - + + Stores the value on top of the evaluation stack in the local variable list at index 4. + + + + 75 + STLOC5 + - + + + + + + + + + + +
-a-
+ + - + + Stores the value on top of the evaluation stack in the local variable list at index 5. + + + + 76 + STLOC6 + - + + + + + + + + + + +
-a-
+ + - + + Stores the value on top of the evaluation stack in the local variable list at index 6. + + + + 77 + STLOC + - + + + + + + + + + + +
-a-
+ + - + + Stores the value on top of the evaluation stack in the local variable list at a specified index. The index is represented as a 1-byte unsigned integer. + + + + 78 + LDARG0 + - + + + + + + + + +
a
+ + - + + Loads the argument at index 0 onto the evaluation stack. + + + + 79 + LDARG1 + - + + + + + + + + +
a
+ + - + + Loads the argument at index 1 onto the evaluation stack. + + + + 7A + LDARG2 + - + + + + + + + + +
a
+ + - + + Loads the argument at index 2 onto the evaluation stack. + + + + 7B + LDARG3 + - + + + + + + + + +
a
+ + - + + Loads the argument at index 3 onto the evaluation stack. + + + + 7C + LDARG4 + - + + + + + + + + +
a
+ + - + + Loads the argument at index 4 onto the evaluation stack. + + + + 7D + LDARG5 + - + + + + + + + + +
a
+ + - + + Loads the argument at index 5 onto the evaluation stack. + + + + 7E + LDARG6 + - + + + + + + + + +
a
+ + - + + Loads the argument at index 6 onto the evaluation stack. + + + + 7F + LDARG + - + + + + + + + + +
a
+ + - + + Loads the argument at a specified index onto the evaluation stack. The index is represented as a 1-byte unsigned integer. + + + + 80 + STARG0 + + + + + + + + +
a
+ + - + - + + Stores the value on top of the evaluation stack in the argument slot at index 0. + + + + 81 + STARG1 + + + + + + + + + + +
-a-
+ + - + - + + Stores the value on top of the evaluation stack in the argument slot at index 1. + + + + 82 + STARG2 + + + + + + + + + + +
-a-
+ + - + - + + Stores the value on top of the evaluation stack in the argument slot at index 2. + + + + 83 + STARG3 + + + + + + + + + + +
-a-
+ + - + - + + Stores the value on top of the evaluation stack in the argument slot at index 3. + + + + 84 + STARG4 + + + + + + + + + + +
-a-
+ + - + - + + Stores the value on top of the evaluation stack in the argument slot at index 4. + + + + 85 + STARG5 + + + + + + + + + + +
-a-
+ + - + - + + Stores the value on top of the evaluation stack in the argument slot at index 5. + + + + 86 + STARG6 + + + + + + + + + + +
-a-
+ + - + - + + Stores the value on top of the evaluation stack in the argument slot at index 6. + + + + 87 + STARG + + + + + + + + + + +
-a-
+ + - + - + + Stores the value on top of the evaluation stack in the argument slot at a specified index. The index is represented as a 1-byte unsigned integer. + + + + 88 + NEWBUFFER + - + + + + + + + + +
a
+ + new Buffer(a) + + Creates a new Buffer and pushes it onto the stack. + + + + 89 + MEMCPY + + + + + + + + + + + + +
edcba
+ - + c.Slice(d, e).CopyTo(a.InnerBuffer.Span[b..]) + + Copies a range of bytes from one Buffer to another. Using this opcode will require to dup the destination buffer. + + + + 8B + CAT + + + + + + + + + +
ba
+ + + + + + + + + +
a.Concat(b)
+ + a.Concat(b) + + Concatenates two strings. + + + + 8C + SUBSTR + + + + + + + + + + +
cba
+ + + + + + + + + +
a.Slice(b, c)
+ + a.Slice(b, c) + + Concatenates two strings. + + + + 8D + LEFT + + + + + + + + + +
ba
+ + + + + + + + + +
a[..b]
+ + a[..b] + + Keeps only characters left of the specified point in a string. + + + + 90 + INVERT + + + + + + + + +
a
+ + + + + + + + + +
~a
+ + ~a + + Flips all the bits in the input. + + + + 91 + AND + + + + + + + + + +
ba
+ + + + + + + + + +
a&b
+ + a&b + + Boolean and between each bit in the inputs. + + + + 92 + OR + + + + + + + + + +
ba
+ + + + + + + + + +
a|b
+ + a|b + + Boolean or between each bit in the inputs. + + + + 93 + XOR + + + + + + + + + +
ba
+ + + + + + + + + +
a^b
+ + a^b + + Boolean exclusive or between each bit in the inputs. + + + + 97 + EQUAL + + + + + + + + + +
ba
+ + + + + + + + + +
a.Equals(b)
+ + a.Equals(b) + + Returns 1 if the inputs are exactly equal, 0 otherwise. + + + + 98 + NOTEQUAL + + + + + + + + + +
ba
+ + + + + + + + + +
!a.Equals(b)
+ + !a.Equals(b) + + Returns 1 if the inputs are not equal, 0 otherwise. + + + + 99 + SIGN + + + + + + + + +
a
+ + + + + + + + + +
a.Sign
+ + + a.Sign + + + Puts the sign of top stack item on top of the main stack. If value is negative, put -1; if positive, put 1; if value is zero, put 0. + + + + 9A + ABS + + + + + + + + +
a
+ + + + + + + + + +
abs(a)
+ + + abs(a) + + + The input is made positive. + + + + 9B + NEGATE + + + + + + + + +
a
+ + + + + + + + + +
-a
+ + + -a + + + The sign of the input is flipped. + + + + 9C + INC + + + + + + + + +
a
+ + + + + + + + + +
a+1
+ + + a+1 + + + 1 is added to the input. + + + + 9D + DEC + + + + + + + + +
a
+ + + + + + + + + +
a-1
+ + + a-1 + + + 1 is subtracted from the input. + + + + 9E + ADD + + + + + + + + + +
ba
+ + + + + + + + + +
a+b
+ + + a+b + + + a is added to b. + + + + 9F + SUB + + + + + + + + + +
ba
+ + + + + + + + + +
a-b
+ + + a-b + + + b is subtracted from a. + + + + A0 + MUL + + + + + + + + + +
ba
+ + + + + + + + + +
a*b
+ + + a*b + + + a is multiplied by b. + + + + A1 + DIV + + + + + + + + + +
ba
+ + + + + + + + + +
a/b
+ + + a/b + + + a is divided by b. + + + + A2 + MOD + + + + + + + + + +
ba
+ + + + + + + + + +
a%b
+ + + a%b + + + Returns the remainder after dividing a by b. + + + + A3 + POW + + + + + + + + + +
ba
+ + + + + + + + + +
a^b
+ + + a^b + + + The result of raising value to the exponent power. + + + + A4 + SQRT + + + + + + + + +
a
+ + + + + + + + + +
sqrt(a)
+ + + sqrt(a) + + + Returns the square root of a specified number. + + + + A5 + MODMUL + + + + + + + + + + +
cba
+ + + + + + + + + +
a*b%c
+ + + a*b%c + + + Performs modulus division on a number multiplied by another number. + - 99 - SIGN + A6 + MODPOW + + @@ -1483,26 +3679,27 @@ Advanced operations with special effects.
cb a
- +
a.Signmodpow(a, b, c)
- a.Sign + modpow(a, b, c) - Puts the sign of top stack item on top of the main stack. If value is negative, put -1; if positive, put 1; if value is zero, put 0. + Performs modulus division on a number raised to the power of another number. If the exponent is -1, it will have the calculation of the modular inverse. - 9A - ABS + A8 + SHL + @@ -1513,26 +3710,27 @@ Advanced operations with special effects.
b a
- +
abs(a)a << b
- abs(a) + a << b - The input is made positive. + Shifts a left b bits, preserving sign. - 9B - NEGATE + A9 + SHR + @@ -1543,22 +3741,22 @@ Advanced operations with special effects.
b a
- +
-aa >> b
- -a + a << b - The sign of the input is flipped. + Shifts a right b bits, preserving sign. - 9C - INC + AA + NOT @@ -1573,26 +3771,27 @@ Advanced operations with special effects.
- +
a+1!a
- a+1 + !a - 1 is added to the input. + If the input is 0 or 1, it is flipped. Otherwise, the output will be 0. - 9D - DEC + AB + BOOLAND + @@ -1603,22 +3802,22 @@ Advanced operations with special effects.
b a
- +
a-1a && b
- a-1 + a && b - 1 is subtracted from the input. + If both a and b are not 0, the output is 1. Otherwise, 0. - 9E - ADD + AC + BOOLOR @@ -1634,22 +3833,52 @@ Advanced operations with special effects.
- +
a+ba || b
- a+b + a || b - a is added to b. + If a or b is not 0, the output is 1. Otherwise, 0. - 9F - SUB + B1 + NZ + + + + + + + + +
a
+ + + + + + + + + +
a != 0
+ + + a != 0 + + + If a or b is not 0, the output is 1. Otherwise, 0. + + + + B3 + NUMEQUAL @@ -1665,21 +3894,231 @@ Advanced operations with special effects.
- +
a-bb == a
- a-b + b == a - b is subtracted from a. + Returns 1 if the numbers are equal, 0 otherwise. + + + + B4 + NUMNOTEQUAL + + + + + + + + + +
ba
+ + + + + + + + + +
b != a
+ + + b != a + + + Returns 1 if the numbers are not equal, 0 otherwise. + + + + B5 + LT + + + + + + + + + +
ba
+ + + + + + + + + +
a < b
+ + + a < b + + + Returns 1 if a is less than b, 0 otherwise. + + + + B6 + LE + + + + + + + + + +
ba
+ + + + + + + + + +
a <= b
+ + + a <= b + + + Returns 1 if a is less than or equal to b, 0 otherwise. + + + + B7 + GT + + + + + + + + + +
ba
+ + + + + + + + + +
a > b
+ + + a > b + + + Returns 1 if a is greater than b, 0 otherwise. + + + + B8 + GE + + + + + + + + + +
ba
+ + + + + + + + + +
a >= b
+ + + a >= b + + + Returns 1 if a is greater than or equal to b, 0 otherwise. + + + + B9 + MIN + + + + + + + + + +
ba
+ + + + + + + + + +
min(a, b)
+ + - + + Returns the smallest of a and b. - Unfinished to be continued... + BA + MAX + + + + + + + + + +
ba
+ + + + + + + + + +
max(a, b)
+ + - + + Returns the largest of a and b. + From 96d27247beb64d9114306d4ef8d72cedfe4e06a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 10 Sep 2024 11:56:10 +0800 Subject: [PATCH 04/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 706 ++++++++++++++++++++++++++++++++++- 1 file changed, 704 insertions(+), 2 deletions(-) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index 61c050b..4c26c52 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -3987,7 +3987,7 @@ Advanced operations with special effects. - + @@ -4049,7 +4049,7 @@ Advanced operations with special effects.
a <= ba ≤ b
- + @@ -4120,6 +4120,708 @@ Advanced operations with special effects. Returns the largest of a and b. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
a >= ba ≥ b
BBWITHIN + + + + + + + + + +
bax
+
+ + + + + + + +
a ≤ x < b
+
- + Returns 1 if x is within the specified range (left-inclusive), 0 otherwise. +
BEPACKMAP + + + + + + + + + +
item...item
+
+ + + + + + + +
map
+
- + A value n is taken from top of main stack. The next n*2 items on main stack are removed, put inside n-sized map and this map is put on top of the main stack. +
BFPACKSTRUCT + + + + + + + + + +
item...item
+
+ + + + + + + +
struct
+
- + A value n is taken from top of main stack. The next n items on main stack are removed, put inside n-sized struct and this struct is put on top of the main stack. +
C0PACK + + + + + + + + + +
item...item
+
+ + + + + + + +
array
+
- + A value n is taken from top of main stack. The next n items on main stack are removed, put inside n-sized array and this array is put on top of the main stack. +
C1UNPACK + + + + + + + +
collection
+
+ + + + + + + + + +
item...item
+
- + A collection is removed from top of the main stack. Its elements are put on top of the main stack (in reverse order) and the collection size is also put on main stack. +
C2NEWARRAY0- + + + + + + + +
new Array[0]
+
- + An empty array (with size 0) is put on top of the main stack. +
C3NEWARRAY + + + + + + + +
n
+
+ + + + + + + +
new Array[n]
+
- + A value n is taken from top of main stack. A null-filled array with size n is put on top of the main stack. +
C4NEWARRAY_T + + + + + + + +
T
+
+ + + + + + + +
new T[n]
+
- + A value n is taken from top of main stack. An array of type T with size n is put on top of the main stack. +
C5NEWSTRUCT0- + + + + + + + +
empty struct
+
- + An empty struct (with size 0) is put on top of the main stack. +
C6NEWSTRUCT + + + + + + + +
n
+
+ + + + + + + +
zero-filled struct with size n
+
- + A value n is taken from top of main stack. A zero-filled struct with size n is put on top of the main stack. +
C8NEWMAP- + + + + + + + +
new Map()
+
- + A Map is created and put on top of the main stack. +
CASIZE + + + + + + + +
a
+
+ + + + + + + +
sizeof(a)
+
- + An array is removed from top of the main stack. Its size is put on top of the main stack. +
CBHASKEY + + + + + + + + +
arrayn
+
+ + + + + + + +
True/False
+
- + An input index n (or key) and an array (or map) are removed from the top of the main stack. Puts True on top of main stack if array[n] (or map[n]) exist, and False otherwise. +
CCKEYS + + + + + + + +
map
+
+ + + + + + + +
keys
+
- + A map is taken from top of the main stack. The keys of this map are put on top of the main stack. +
CDVALUES + + + + + + + +
map
+
+ + + + + + + +
values
+
- + A map is taken from top of the main stack. The values of this map are put on top of the main stack. +
CEPICKITEM + + + + + + + + +
arrayn
+
+ + + + + + + +
array[n]
+
- + An input index n (or key) and an array (or map) are taken from main stack. Element array[n] (or map[n]) is put on top of the main stack. +
CFAPPEND + + + + + + + + +
ba
+
+ + + + + + + +
a.concat(b)
+
- + The item on top of main stack is removed and appended to the second item on top of the main stack. +
D0SETITEM + + + + + + + + + +
arraynv
+
+ + + + + + + +
array (array[n]=v)
+
- + A value v, index n (or key) and an array (or map) are taken from main stack. Attribution array[n]=v (or map[n]=v) is performed. +
D1REVERSEITEMS + + + + + + + +
array
+
-- + An array is removed from the top of the main stack and its elements are reversed. +
D2REMOVE + + + + + + + + +
arrayn
+
-- + An input index n (or key) and an array (or map) are removed from the top of the main stack. Element array[n] (or map[n]) is removed. +
D3CLEARITEMS + + + + + + + +
items
+
-- + Remove all the items from the compound-type. +
D4POPITEM + + + + + + + +
array
+
+ + + + + + + +
array[i]
+
- + Remove the last element from an array, and push it onto the stack. +
D8ISNULL + + + + + + + +
a
+
+ + + + + + + +
a == null
+
- + Returns true if the input is null; +
D9ISTYPE + + + + + + + +
a
+
+ + + + + + + +
a is T
+
- + Returns true if the top item of the stack is of the specified type; +
DBCONVERT + + + + + + + +
a
+
+ + + + + + + +
(T)a
+
- + Converts the top item of the stack to the specified type. +
E0ABORTMSG + + + + + + + +
a
+
-- + Pops the top stack item. Then, turns the vm state to FAULT immediately, and cannot be caught. The top stack +
E1ASSERTMSG + + + + + + + + +
ba
+
-- + Pops the top two stack items. If the second-to-top stack value is false, exits the vm execution and sets the vm state to FAULT. In this case, the top stack value is used as reason for the exit. Otherwise, it is ignored. +
From cc9b5da3340a70639aa11e7c419793f7c3deae2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 10 Sep 2024 12:00:46 +0800 Subject: [PATCH 05/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index 4c26c52..ad45cdf 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -4303,7 +4303,7 @@ Advanced operations with special effects. - + @@ -4331,7 +4331,7 @@ Advanced operations with special effects.
new Array[n]new Array\[n\]
- + @@ -4462,7 +4462,7 @@ Advanced operations with special effects. @@ -4539,7 +4539,7 @@ Advanced operations with special effects.
new T[n]new T\[n\]
- - An input index n (or key) and an array (or map) are removed from the top of the main stack. Puts True on top of main stack if array[n] (or map[n]) exist, and False otherwise. + An input index n (or key) and an array (or map) are removed from the top of the main stack. Puts True on top of main stack if array\[n\] (or map\[n\]) exist, and False otherwise.
- + @@ -4547,7 +4547,7 @@ Advanced operations with special effects. @@ -4598,7 +4598,7 @@ Advanced operations with special effects.
array[n]array\[n\]
- - An input index n (or key) and an array (or map) are taken from main stack. Element array[n] (or map[n]) is put on top of the main stack. + An input index n (or key) and an array (or map) are taken from main stack. Element array\[n\] (or map\[n\]) is put on top of the main stack.
- + @@ -4606,7 +4606,7 @@ Advanced operations with special effects. @@ -4645,7 +4645,7 @@ Advanced operations with special effects. @@ -4818,10 +4818,6 @@ Advanced operations with special effects. Pops the top two stack items. If the second-to-top stack value is false, exits the vm execution and sets the vm state to FAULT. In this case, the top stack value is used as reason for the exit. Otherwise, it is ignored. - - - -
array (array[n]=v)array (array\[n\]=v)
- - A value v, index n (or key) and an array (or map) are taken from main stack. Attribution array[n]=v (or map[n]=v) is performed. + A value v, index n (or key) and an array (or map) are taken from main stack. Attribution array\[n\]=v (or map\[n\]=v) is performed.
- - - An input index n (or key) and an array (or map) are removed from the top of the main stack. Element array[n] (or map[n]) is removed. + An input index n (or key) and an array (or map) are removed from the top of the main stack. Element array\[n\] (or map\[n\]) is removed.
From a78def047e3d1ad3786a48b289f3be1cc4a1fbc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 10 Sep 2024 13:16:32 +0800 Subject: [PATCH 06/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index ad45cdf..cb7dba5 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -1875,8 +1875,8 @@ Advanced operations with special effects. - 54 - REVERSE4 + 55 + REVERSEN From bbabd0e0e791aaab967c0c03332b2add627d5783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 10 Sep 2024 13:20:21 +0800 Subject: [PATCH 07/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index cb7dba5..98715db 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -2856,7 +2856,7 @@ Advanced operations with special effects. - +
8383 STARG3 From 927c391ea475013fee096a5748d2ab855871cce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 10 Sep 2024 14:07:55 +0800 Subject: [PATCH 08/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index 98715db..584b8d1 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -2081,7 +2081,6 @@ Advanced operations with special effects. - + @@ -2110,7 +2110,6 @@ Advanced operations with special effects. - + @@ -2141,7 +2141,6 @@ Advanced operations with special effects. - + @@ -2172,7 +2172,6 @@ Advanced operations with special effects. - + @@ -2203,7 +2203,6 @@ Advanced operations with special effects. - + @@ -2234,7 +2234,6 @@ Advanced operations with special effects. - + @@ -2265,7 +2265,6 @@ Advanced operations with special effects. - + @@ -2296,7 +2296,6 @@ Advanced operations with special effects. - + @@ -2328,7 +2328,6 @@ Advanced operations with special effects. - + @@ -2347,7 +2347,6 @@ Advanced operations with special effects. - + @@ -2366,7 +2366,6 @@ Advanced operations with special effects. - + @@ -2385,7 +2385,6 @@ Advanced operations with special effects. - + @@ -2404,7 +2404,6 @@ Advanced operations with special effects. - + @@ -2423,7 +2423,6 @@ Advanced operations with special effects. - + @@ -2442,7 +2442,6 @@ Advanced operations with special effects. - + @@ -2461,7 +2461,6 @@ Advanced operations with special effects. - + From 1374e8ed7ca9613e185085444e88877121560e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Wed, 11 Sep 2024 15:11:45 +0800 Subject: [PATCH 09/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index 584b8d1..30dfa8c 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -4820,4 +4820,9 @@ Advanced operations with special effects.
60 STSFLD0- @@ -2103,6 +2102,7 @@ Advanced operations with special effects.
- Stores the value on top of the evaluation stack in the static field list at index 0.
61 STSFLD1- @@ -2134,6 +2133,7 @@ Advanced operations with special effects.
- Stores the value on top of the evaluation stack in the static field list at index 1.
62 STSFLD2- @@ -2165,6 +2164,7 @@ Advanced operations with special effects.
- Stores the value on top of the evaluation stack in the static field list at index 2.
63 STSFLD3- @@ -2196,6 +2195,7 @@ Advanced operations with special effects.
- Stores the value on top of the evaluation stack in the static field list at index 0.
64 STSFLD4- @@ -2227,6 +2226,7 @@ Advanced operations with special effects.
- Stores the value on top of the evaluation stack in the static field list at index 4.
65 STSFLD5- @@ -2258,6 +2257,7 @@ Advanced operations with special effects.
- Stores the value on top of the evaluation stack in the static field list at index 5.
66 STSFLD6- @@ -2289,6 +2288,7 @@ Advanced operations with special effects.
- Stores the value on top of the evaluation stack in the static field list at index 6.
67 STSFLD- @@ -2320,6 +2319,7 @@ Advanced operations with special effects.
- Stores the value on top of the evaluation stack in the static field list at a specified index. The index is represented as a 1-byte unsigned integer. 68 LDLOC0 -- @@ -2339,6 +2338,7 @@ Advanced operations with special effects.
- Loads the local variable at index 0 onto the evaluation stack. 69 LDLOC1 -- @@ -2358,6 +2357,7 @@ Advanced operations with special effects.
- Loads the local variable at index 1 onto the evaluation stack. 6A LDLOC2 -- @@ -2377,6 +2376,7 @@ Advanced operations with special effects.
- Loads the local variable at index 2 onto the evaluation stack. 6B LDLOC3 -- @@ -2396,6 +2395,7 @@ Advanced operations with special effects.
- Loads the local variable at index 3 onto the evaluation stack. 6C LDLOC4 -- @@ -2415,6 +2414,7 @@ Advanced operations with special effects.
- Loads the local variable at index 4 onto the evaluation stack. 6D LDLOC5 -- @@ -2434,6 +2433,7 @@ Advanced operations with special effects.
- Loads the local variable at index 5 onto the evaluation stack. 6E LDLOC6 -- @@ -2453,6 +2452,7 @@ Advanced operations with special effects.
- Loads the local variable at index 7 onto the evaluation stack. 6F LDLOC -- @@ -2472,6 +2471,7 @@ Advanced operations with special effects.
- Loads the local variable at a specified index onto the evaluation stack. The index is represented as a 1-byte unsigned integer.
+## Reference + +Definition of OpCodes in Neo https://github.com/neo-project/neo/blob/master/src/Neo.VM/OpCode.cs + +OpCodes implementation in NeoVM: https://github.com/neo-project/neo/tree/master/src/Neo.VM/JumpTable From a2c23787352139b757711530ff56ef6323c6484a Mon Sep 17 00:00:00 2001 From: Celia18305 Date: Wed, 11 Sep 2024 15:36:08 +0800 Subject: [PATCH 10/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 44 ++++++++++++------------------------ 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index 584b8d1..a78ba33 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -2,7 +2,7 @@ sidebar_label: 'NeoVM OpCodes' --- -# Neo Virtual Machine OpCodes +# Neo Virtual Machine Opcodes Use this handy table to skip ahead to the [opcode reference](#opcodes). @@ -299,53 +299,39 @@ Use this handy table to skip ahead to the [opcode reference](#opcodes).
-## OverView +## Overview -This OpCode collection defines a set of instructions for handling stack operations, compound-type operations, bitwise -logic, arithmetic calculations, and more. +This opcode set defines instructions for stack operations, compound-type handling, bitwise logic, arithmetic calculations, and more. - **Constants** -These opcodes are used to push constant values onto the stack. Included are instructions for pushing integers of -different sizes (e.g., signed integers from 1 byte to 32 bytes) onto the stack (PUSHINT8 through PUSHINT256), as well as -instructions for pushing Boolean values true (PUSHT) and false (PUSHF). Also included are opcodes for pushing pointers -(PUSHA), nulls (PUSHNULL), data blocks (PUSHDATA1 through PUSHDATA4), and fixed values (PUSHM1 through PUSH16) onto the -stack. - -Translated with DeepL.com (free version) + Constants opcodes push constant values onto the stack. These include instructions for pushing integers of various sizes (e.g., signed integers from 1 byte to 32 bytes), with opcodes ranging from PUSHINT8 to PUSHINT256. Additionally, there are instructions for pushing Boolean values (PUSHT for true and PUSHF for false), pointers (PUSHA), null values (PUSHNULL), data blocks (PUSHDATA1 through PUSHDATA4), and fixed values (PUSHM1 through PUSH16) onto the stack. - **Flow Control** -Flow control opcodes are used to control the flow of program execution. These instructions are typically used for -operations such as conditional jumps, loops, and method calls to implement complex logic control. +Flow control opcodes manage the program execution flow. They are typically used for conditional jumps, loops, and method calls, enabling the implementation of complex logic control. - **Stack** -Stack opcodes are used to manipulate data on the stack and support push, pop, duplicate and swap operations. They play -an important role in data manipulation and management to ensure that data can be efficiently manipulated and transferred -as expected. +Stack opcodes handle data manipulation on the stack, supporting push, pop, duplicate, and swap operations. These are crucial for efficient data handling and transfer. - **Slot** -The Slot opcode is used to manage the operation of local variable slots. These instructions allow data to be stored into -or loaded from specific slots to support the management of local variables and parameters. +The slot opcode manages local variable slots so that data can be stored or retrieved from specific slots, facilitating the management of local variables and parameters. - **Splice** -The splice opcode is used to handle splice, split, and extract operations on byte arrays and strings. These instructions -can be used to merge multiple chunks of data or to extract portions of existing data. +The splice opcode handles splice, split, and extract operations on byte arrays and strings. These instructions can be used to merge multiple data chunks or extract portions of existing data. - **Bitwise Logic** -Bitwise logical opcodes are used to perform bitwise operations (e.g., AND, OR, XOR, NOT, etc.) that are typically used -in low-level data processing, such as encryption and compression algorithms. +Bitwise logical opcodes perform bitwise operations (e.g., AND, OR, XOR, NOT, etc.) commonly used +in low-level data processing tasks, such as encryption and compression algorithms. - **Arithmetic** -Arithmetic opcodes are used to perform basic arithmetic operations (such as addition, subtraction, multiplication, -division, etc.). These operations are very useful in implementing data calculations and numerical processing. +Arithmetic opcodes perform basic mathematical operations (e.g., addition, subtraction, multiplication, +division), essential for data calculations and numerical processing. - **Compound-Type** -Complex type opcodes are used to manipulate complex data types such as arrays, structures, and other custom types. These -instructions are used to create, modify and destroy complex data types. +Compound-type opcodes manipulate complex data types like arrays, structures, and custom types. These instructions are used to create, modify and destroy complex data types. - **Types** -Type opcodes are used to handle and manipulate the conversion and checking of data types. These instructions are used to -determine the type of data or to convert one type to another. +Type opcodes manage data type conversion and checking. They are used to determine the data type or convert one type to another. - **Extensions** Advanced operations with special effects. @@ -362,7 +348,7 @@ Advanced operations with special effects. Stack Input Stack Output Expression - Notes + Descriptions From b83493cfcfcd292d954f06274d37c372e741cb80 Mon Sep 17 00:00:00 2001 From: Celia18305 Date: Wed, 11 Sep 2024 15:41:33 +0800 Subject: [PATCH 11/12] Update Opcodes.md --- docs/n3/reference/Opcodes.md | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/docs/n3/reference/Opcodes.md b/docs/n3/reference/Opcodes.md index d30b4f8..4417c83 100644 --- a/docs/n3/reference/Opcodes.md +++ b/docs/n3/reference/Opcodes.md @@ -308,33 +308,42 @@ This opcode set defines instructions for stack operations, compound-type handlin Constants opcodes push constant values onto the stack. These include instructions for pushing integers of various sizes (e.g., signed integers from 1 byte to 32 bytes), with opcodes ranging from PUSHINT8 to PUSHINT256. Additionally, there are instructions for pushing Boolean values (PUSHT for true and PUSHF for false), pointers (PUSHA), null values (PUSHNULL), data blocks (PUSHDATA1 through PUSHDATA4), and fixed values (PUSHM1 through PUSH16) onto the stack. - **Flow Control** -Flow control opcodes manage the program execution flow. They are typically used for conditional jumps, loops, and method calls, enabling the implementation of complex logic control. + + Flow control opcodes manage the program execution flow. They are typically used for conditional jumps, loops, and method calls, enabling the implementation of complex logic control. - **Stack** -Stack opcodes handle data manipulation on the stack, supporting push, pop, duplicate, and swap operations. These are crucial for efficient data handling and transfer. + + Stack opcodes handle data manipulation on the stack, supporting push, pop, duplicate, and swap operations. These are crucial for efficient data handling and transfer. - **Slot** -The slot opcode manages local variable slots so that data can be stored or retrieved from specific slots, facilitating the management of local variables and parameters. + + The slot opcode manages local variable slots so that data can be stored or retrieved from specific slots, facilitating the management of local variables and parameters. - **Splice** -The splice opcode handles splice, split, and extract operations on byte arrays and strings. These instructions can be used to merge multiple data chunks or extract portions of existing data. + + The splice opcode handles splice, split, and extract operations on byte arrays and strings. These instructions can be used to merge multiple data chunks or extract portions of existing data. - **Bitwise Logic** -Bitwise logical opcodes perform bitwise operations (e.g., AND, OR, XOR, NOT, etc.) commonly used -in low-level data processing tasks, such as encryption and compression algorithms. + + Bitwise logical opcodes perform bitwise operations (e.g., AND, OR, XOR, NOT, etc.) commonly used + in low-level data processing tasks, such as encryption and compression algorithms. - **Arithmetic** -Arithmetic opcodes perform basic mathematical operations (e.g., addition, subtraction, multiplication, -division), essential for data calculations and numerical processing. + + Arithmetic opcodes perform basic mathematical operations (e.g., addition, subtraction, multiplication, + division), essential for data calculations and numerical processing. - **Compound-Type** -Compound-type opcodes manipulate complex data types like arrays, structures, and custom types. These instructions are used to create, modify and destroy complex data types. + + Compound-type opcodes manipulate complex data types like arrays, structures, and custom types. These instructions are used to create, modify and destroy complex data types. - **Types** -Type opcodes manage data type conversion and checking. They are used to determine the data type or convert one type to another. + + Type opcodes manage data type conversion and checking. They are used to determine the data type or convert one type to another. - **Extensions** -Advanced operations with special effects. + + Advanced operations with special effects. ## OpCodes From 488ac11f681037219299ddcce86048b5ad8ff307 Mon Sep 17 00:00:00 2001 From: Celia18305 Date: Fri, 13 Sep 2024 11:16:42 +0800 Subject: [PATCH 12/12] Delete Neo VM instructions.md --- docs/n3/Advances/Neo VM instructions.md | 1128 ----------------------- 1 file changed, 1128 deletions(-) delete mode 100644 docs/n3/Advances/Neo VM instructions.md diff --git a/docs/n3/Advances/Neo VM instructions.md b/docs/n3/Advances/Neo VM instructions.md deleted file mode 100644 index 5031833..0000000 --- a/docs/n3/Advances/Neo VM instructions.md +++ /dev/null @@ -1,1128 +0,0 @@ -# NeoVM Instructions - -## Built-in data types - -NeoVM has following built-in data types: - -| Type | Description | -|------|------| -| Array | Implemented as a `List`, the `StackItem` is an abstract class, and all the built-in data types are inherited from it. | -| Boolean | Implemented as two byte arrays, `TRUE` and `FALSE`. | -| Buffer | Readonly byte array, implemented as a buffer array `byte[]` | -| ByteString | Readonly byte array, implemented as a `ReadOnlyMemory` | -| Integer | Implemented as a `BigInteger` value. | -| InteropInterface | Interoperable interface | -| Map | Implemented as a key-value pair `Dictionary`. | -| Null | Null type | -| Pointer | Implemented as a context `Script` and an instruction `Position` | -| Struct | Inherited from Array, a `Clone` method is added and `Equals` method is overridden. | - -- `CompoundType` : Compound type, which includes `Array`, `Map` and `Struct`。 -- `PrimitiveType`: Basic type which includes `Boolean`, `ByteString` and `Integer`。 - -```cs -// boolean type -private static readonly byte[] TRUE = { 1 }; -private static readonly byte[] FALSE = { 0 }; - -private bool value; -``` - -## Instructions - -NeoVM has implemented 189 instructions. The categories are as follows: - -| Constant | Flow Control | Stack Operation | Slot Operation |String Operation | Logical Operation | Arithmetic Operation | Advanced Data Structure | Type Operation | -| ---- | -------- | ------ | ------ | -------- | -------- | -------- | ---- | ---- | -| 29 | 32 | 15 | 50 | 6 | 6 | 25 | 18 | 3| - -Details of each instruction in each category are introduced as follows. - -### Constants - -The constant instructions mainly complete the function of pushing constants or arrays into the `EvaluationStack`. - -#### PUSHINT - -| Instruction | PUSHINT8, PUSHINT16, PUSHINT32, PUSHINT64, PUSHINT128, PUSHINT256 | -|----------|---------------------------------------| -| Bytecode | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 | -| Fee | 0.00000001 GAS, 0.00000001 GAS, 0.00000001 GAS, 0.00000001 GAS, 0.00000004 GAS, 0.00000004 GAS | -| Function | Push an integer onto the stack, the bit length of which is specified with the number 8\16\32\64\128\256. | - -#### PUSHT/PUSHF - -| Instruction | PUSHT, PUSHF | -| ----------- | ------------------------------------------------- | -| Bytecode | 0x08, 0x09 | -| Fee | 0.00000001 GAS | -| Function | Push the Boolean value True/False onto the stack. | - -#### PUSHA - -| Instruction | PUSHA | -|----------|----------| -| Bytecode | 0x0A | -| Fee | 0.00000004 GAS | -| Function | Convert the next four bytes to an address, and push the address onto the stack. | - -#### PUSHNULL - -| Instruction | PUSHNULL | -|----------|------------------------------------------| -| Bytecode | 0x0B | -| Fee | 0.00000001 GAS | -| Function | The item `null` is pushed onto the stack. | - -#### PUSHDATA - -| Instruction | PUSHDATA1, PUSHDATA2, PUSHDATA4 | -|----------|---------------------------------------| -| Bytecode | 0x0C, 0x0D, 0x0E | -| Fee | 0.00000008 GAS, 0.00000512 GAS, 0.00004096 GAS | -| Function | The next `n` bytes contain the number of bytes to be pushed onto the stack, where n is specified by 1\|2\|4. | - -#### PUSHM1 - -| Instruction | PUSHM1 | -|----------|------------------------------------------| -| Bytecode | 0x0F | -| Fee | 0.00000001 GAS | -| Function | The number -1 is pushed onto the stack. | - -#### PUSHN - -| Instruction | PUSH0\~PUSH16 | -|----------|---------------------------------------------| -| Bytecode | 0x10\~0x20 | -| Fee | 0.00000001 GAS | -| Function | The number `n` is pushed onto the stack,where n is specified by 0\~16. | - -### Flow Control - -It's used to control the running process of NeoVM, including jump, call and other instructions. - -#### NOP - -| Instruction | NOP | -|----------|---------------------------------------------| -| Bytecode | 0x21 | -| Fee | 0.00000001 GAS | -| Function | The `NOP` operation does nothing. It is intended to fill in space if opcodes are patched. | - -#### JMP - -| Instruction | JMP | -|----------|---------------------------------------------------------| -| Bytecode | 0x22 | -| Fee | 0.00000002 GAS | -| Function | Unconditionally transfers control to a target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### JMP_L - -| Instruction | JMP_L | -|----------|---------------------------------------------------------| -| Bytecode | 0x23 | -| Fee | 0.00000002 GAS | -| Function | Unconditionally transfers control to a target instruction. The target instruction is represented as a 4-bytes signed offset from the beginning of the current instruction.| - -#### JMPIF - -| Instruction | JMPIF | -|----------|----------------------------------------------------------------------------------------------------------------------| -| Bytecode | 0x24 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the value is `true`, not `null`, or non-zero. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction.| - -#### JMPIF_L - -| Instruction | JMPIF | -|----------|----------------------------------------------------------------------------------------------------------------------| -| Bytecode | 0x25 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the value is `true`, not `null`, or non-zero. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### JMPIFNOT - -| Instruction | JMPIFNOT | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x26 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the value is `false`, a `null` reference, or zero. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### JMPIFNOT_L - -| Instruction | JMPIFNOT_L | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x27 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the value is `false`, a `null` reference, or zero. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### JMPEQ - -| Instruction | JMPEQ | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x28 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if two values are equal. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### JMPEQ_L - -| Instruction | JMPEQ_L | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x29 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if two values are equal. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### JMPNE - -| Instruction | JMPNE | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x2A | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction when two values are not equal. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### JMPNE_L - -| Instruction | JMPNE_L | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x2B | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction when two values are not equal. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### JMPGT - -| Instruction | JMPGT | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x2C | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the first value is greater than the second value. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### JMPGT_L - -| Instruction | JMPGT_L | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x2D | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the first value is greater than the second value. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### JMPGE - -| Instruction | JMPGE | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x2E | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the first value is greater than or equal to the second value. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### JMPGE_L - -| Instruction | JMPGE_L | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x2F | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the first value is greater than or equal to the second value. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### JMPLT - -| Instruction | JMPLT | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x30 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the first value is less than the second value. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### JMPLT_L - -| Instruction | JMPLT_L | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x31 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the first value is less than the second value. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### JMPLE - -| Instruction | JMPLE | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x32 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the first value is less than or equal to the second value. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### JMPLE_L - -| Instruction | JMPLE_L | -|----------|--------------------------------------------------------------------| -| Bytecode | 0x33 | -| Fee | 0.00000002 GAS | -| Function | Transfers control to a target instruction if the first value is less than or equal to the second value. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### CALL - -| Instruction | CALL | -|----------|-------------------------------------------------------| -| Bytecode | 0x34 | -| Fee | 0.00000512 GAS | -| Function | Calls the function at the target address which is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### CALL_L - -| Instruction | CALL_L | -|----------|-------------------------------------------------------| -| Bytecode | 0x35 | -| Fee | 0.00000512 GAS | -| Function | Calls the function at the target address which is represented as a 4-bytes signed offset from the beginning of the current instruction. | - -#### CALLA - -| Instruction | CALLA | -|----------|-------------------------------------------------------| -| Bytecode | 0x36 | -| Fee | 0.00000512 GAS | -| Function | Pops the address of a function from the stack, and call the function. | - -#### CALLT - -| Instruction | CALLT | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0x37 | -| Fee | 0.00032768 GAS | -| Function | Pops the function Token from the stack, and call the function. | - -#### ABORT - -| Instruction | ABORT | -|----------|-------------------------------------------------------| -| Bytecode | 0x38 | -| Fee | 0 GAS | -| Function | It turns the vm state to FAULT immediately, and the exception cannot be caught. | - -#### ASSERT - -| Instruction | ASSERT | -|----------|------------------------------------------------------------------| -| Bytecode | 0x39 | -| Fee | 0.00000001 GAS | -| Function | Pop the top value of the stack, if it is false, then exit vm execution and set vm state to FAULT. | - -#### THROW - -| Instruction | THROW | -|----------|-----------------------| -| Bytecode | 0x3A | -| Fee | 0.00000512 GAS | -| Function | Throws the exception of stack top | - -#### TRY - -| Instruction | TRY | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0x3B | -| Fee | 0.00000004 GAS | -| Function | Enters the block of Try statement. The Catch and Finally address offset are represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### TRY_L - -| Instruction | TRY_L | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0x3C | -| Fee | 0.00000004 GAS | -| Function | Enters the block of Try statement. The Catch and Finally address offset are represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### ENDTRY - -| Instruction | ENDTRY | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0x3D | -| Fee | 0.00000004 GAS | -| Function | Terminates the block Try and unconditionally transfers control to a target instruction. The target instruction is represented as a 1-byte signed offset from the beginning of the current instruction. | - -#### ENDTRY_L - -| Instruction | ENDTRY_L | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0x3E | -| Fee | 0.00000004 GAS | -| Function | Terminates the block Try and unconditionally transfers control to a target instruction. The target instruction is represented as a 4-byte signed offset from the beginning of the current instruction. | - -#### ENDFINALLY - -| Instruction | ENDFINALLY | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0x3F | -| Fee | 0.00000004 GAS | -| Function | Terminates the block Finally and goes to the target instruction ENDTRY/ENDTRY_L if there is no exception, or throw the exception to the upper level again. | - -#### RET - -| Instruction | RET | -|----------|--------------------------------------------------------------------------------------------------| -| Bytecode | 0x40 | -| Fee | 0 GAS | -| Function | Returns from the current method. | - -#### SYSCALL - -| Instruction | SYSCALL | -|----------|--------------------------------------------------------| -| Bytecode | 0x41 | -| Fee | 0 GAS | -| Function | Calls to an interop service. | - -### Stack Operation - -Copy, remove and swap the elements of the stack. - -#### DEPTH - -| Instruction | DEPTH | -|----------|------------------------------------------| -| Bytecode | 0x43 | -| Fee | 0.00000002 GAS | -| Function | Puts the number of stack items onto the stack. | - -#### DROP - -| Instruction | DROP | -|----------|------------------------| -| Bytecode | 0x45 | -| Fee | 0.00000002 GAS | -| Function | Removes the top stack item. | - -#### NIP - -| Instruction | NIP | -|----------|------------------------------------------| -| Bytecode | 0x46 | -| Fee | 0.00000002 GAS | -| Function | Removes the second-to-top stack item. | - -#### XDROP - -| Instruction | XDROP | -|----------|----------------------------------------------------| -| Bytecode | 0x48 | -| Fee | 0.00000016 GAS | -| Function | The item n back in the main stack is removed. | -| Function | Gets the integer N from the top stack and removes elements indexed to N from the remaining elements of the stack. | - -#### CLEAR - -| Instruction | CLEAR | -|----------|------------------------------------------| -| Bytecode | 0x49 | -| Fee | 0.00000016 GAS | -| Function | Clear the stack | - -#### DUP - -| Instruction | DUP | -|----------|------------------------| -| Bytecode | 0x4A | -| Fee | 0.00000002 GAS | -| Function | Copies the top stack item to the top. | - -#### OVER - -| Instruction | OVER | -|----------|------------------------| -| Bytecode | 0x4B | -| Fee | 0.00000002 GAS | -| Function | Copies the second-to-top stack item to the top. | - -#### PICK - -| Instruction | PICK | -|----------|------------------------| -| Bytecode | 0x4D | -| Fee | 0.00000002 GAS | -| Function | Gets the integer N from the top stack and copies elements indexed to N from the remaining elements of the stack to the top. | - -#### TUCK - -| Instruction | TUCK | -|----------|------------------------| -| Bytecode | 0x4E | -| Fee | 0.00000002 GAS | -| Function | The item at the top of the stack is copied and inserted before the second-to-top item. | - -#### SWAP - -| Instruction | SWAP | -|----------|------------------------| -| Bytecode | 0x50 | -| Fee | 0.00000002 GAS | -| Function | The top two items on the stack are swapped. | - -#### ROT - -| Instruction | ROT | -|----------|------------------------| -| Bytecode | 0x51 | -| Fee | 0.00000002 GAS | -| Function | Moves the elements indexed to 2 to the top | - -#### ROLL - -| Instruction | ROLL | -|----------|------------------------| -| Bytecode | 0x52 | -| Fee | 0.00000016 GAS | -| Function | Gets the integer N from the top stack and moves elements indexed to N from the remaining elements of the stack to the top. | - -#### REVERSE3 - -| Instruction | REVERSE3 | -|----------|------------------------| -| Bytecode | 0x53 | -| Fee | 0.00000002 GAS | -| Function | Reverse the order of the top 3 items on the stack. | - -#### REVERSE4 - -| Instruction | REVERSE4 | -|----------|------------------------| -| Bytecode | 0x54 | -| Fee | 0.00000002 GAS | -| Function | Reverse the order of the top 4 items on the stack. | - -#### REVERSEN - -| Instruction | REVERSEN | -|----------|------------------------| -| Bytecode | 0x55 | -| Fee | 0.00000016 GAS | -| Function | Gets the integer N from the top stack, and reverse the order of the top N items on the stack. | - -### Slot - -#### INITSSLOT - -| Instruction | INITSSLOT | -|----------|---------------------------------------| -| Bytecode | 0x56 | -| Fee | 0.00000016 GAS | -| Function | Initialize the static field list for the current execution context. | - -#### INITSLOT - -| Instruction | INITSLOT | -|----------|---------------------------------------| -| Bytecode | 0x57 | -| Fee | 0.00000064 GAS | -| Function | Initialize the argument slot and the local variable list for the current execution context. | - -#### LDSFLDN - -| Instruction | LDSFLD0\~LDSFLD6 | -|----------|---------------------------------------| -| Bytecode | 0x58\~0x5E | -| Fee | 0.00000002 GAS | -| Function | Loads the static field at index `n` onto the evaluation stack, where the n is 0\~6。 | - -#### LDSFLD - -| Instruction | LDSFLD | -|----------|---------------------------------------| -| Bytecode | 0x5F | -| Fee | 0.00000002 GAS | -| Function | Loads the static field at a specified index onto the evaluation stack. The index is represented as a 1-byte unsigned integer. | - -#### STSFLDN - -| Instruction | STSFLD0\~STSFLD6 | -|----------|---------------------------------------| -| Bytecode | 0x60\~0x0x66 | -| Fee | 0.00000002 GAS | -| Function | Stores the value on top of the evaluation stack in the static field list at index `n`, where the n is 0\~6。 | - -#### STSFLD - -| Instruction | STSFLD | -|----------|---------------------------------------| -| Bytecode | 0x67 | -| Fee | 0.00000002 GAS | -| Function | Stores the value on top of the evaluation stack in the static field list at a specified index. The index is represented as a 1-byte unsigned integer. | - -#### LDLOCN - -| Instruction | LDLOC0\~LDLOC6 | -|----------|---------------------------------------| -| Bytecode | 0x68\~0x6E | -| Fee | 0.00000002 GAS | -| Function | Loads the local variable at index `n` onto the evaluation stack, where the n is 0\~6。 | - -#### LDLOC - -| Instruction | LDLOC | -|----------|---------------------------------------| -| Bytecode | 0x6F | -| Fee | 0.00000002 GAS | -| Function | Loads the local variable at a specified index onto the evaluation stack. The index is represented as a 1-byte unsigned integer. | - -#### STLOCN - -| Instruction | STLOC0\~STLOC6 | -|----------|---------------------------------------| -| Bytecode | 0x70\~0x76 | -| Fee | 0.00000002 GAS | -| Function | Stores the value on top of the evaluation stack in the local variable list at index `n`, where the n is 0\~6。 | - -#### STLOC - -| Instruction | STLOC | -|----------|---------------------------------------| -| Bytecode | 0x77 | -| Fee | 0.00000002 GAS | -| Function | Stores the value on top of the evaluation stack in the local variable list at a specified index. The index is represented as a 1-byte unsigned integer. | - -#### LDARGN - -| Instruction | LDARG0\~LDARG6 | -|----------|---------------------------------------| -| Bytecode | 0x78\~0x7E | -| Fee | 0.00000002 GAS | -| Function | Loads the argument at index `n` onto the evaluation stack, where the n is 0\~6. | - -#### LDARG - -| Instruction | LDARG | -|----------|---------------------------------------| -| Bytecode | 0x7F | -| Fee | 0.00000002 GAS | -| Function | Loads the argument at a specified index onto the evaluation stack. The index is represented as a 1-byte unsigned integer. | - -#### STARGN - -| Instruction | STARG0\~STARG6 | -|----------|---------------------------------------| -| Bytecode | 0x80\~0x86 | -| Fee | 0.00000002 GAS | -| Function | Stores the value on top of the evaluation stack in the argument slot at index `n`, where the n is 0\~6. | - -#### STARG - -| Instruction | STARG | -|----------|--------------------------------------| -| Bytecode | 0x87 | -| Fee | 0.00000002 GAS | -| Function | Stores the value on top of the evaluation stack in the argument slot at a specified index. The index is represented as a 1-byte unsigned integer. | - -### String Operation - -#### NEWBUFFER - -| Instruction | NEWBUFFER | -|----------|--------------------------------------------------| -| Bytecode | 0x88 | -| Fee | 0.00000256 GAS | -| Function | Create a new buffer | - -#### MEMCPY - -| Instruction | MEMCPY | -|----------|--------------------------------------------------| -| Bytecode | 0x89 | -| Fee | 0.00002048 GAS | -| Function | memory copy | - -#### CAT - -| Instruction | CAT | -|----------|--------------------------------------------------| -| Bytecode | 0x8B | -| Fee | 0.00002048 GAS | -| Function | Concatenates two strings. | - -#### SUBSTR - -| Instruction | SUBSTR | -|----------|----------------------------------------------| -| Bytecode | 0x8C | -| Fee | 0.00002048 GAS | -| Function | Returns a section of a string. | - -#### LEFT - -| Instruction | LEFT | -|----------|----------------------------------------------| -| Bytecode | 0x8D | -| Fee | 0.00002048 GAS | -| Function | Gets characters in the left of the specified point in a string. | - -#### RIGHT - -| Instruction | RIGHT | -|----------|----------------------------------------------| -| Bytecode | 0x8E | -| Fee | 0.00002048 GAS | -| Function | Gets characters in the right of the specified point in a string. | - -### Logical Operation - -#### INVERT - -| Instruction | INVERT | -|----------|------------------------------| -| Bytecode | 0x90 | -| Fee | 0.00000004 GAS | -| Function | Flips all of the bits in the input. | - -#### AND - -| Instruction | AND | -|----------|----------------------------------------| -| Bytecode | 0x91 | -| Fee | 0.00000008 GAS | -| Function | Boolean and between each bit in the inputs | - -#### OR - -| Instruction | OR | -|----------|----------------------------------------| -| Bytecode | 0x92 | -| Fee | 0.00000008 GAS | -| Function | Boolean or between each bit in the inputs. | - -#### XOR - -| Instruction | XOR | -|----------|------------------------------------------| -| Bytecode | 0x93 | -| Fee | 0.00000008 GAS | -| Function | Boolean exclusive or between each bit in the inputs. | - -#### EQUAL - -| Instruction | EQUAL | -|----------|----------------------------------------------| -| Bytecode | 0x97 | -| Fee | 0.00000032 GAS | -| Function | Returns 1 if the inputs are exactly equal, 0 otherwise. | - -#### NOTEQUAL - -| Instruction | NOTEQUAL | -|----------|----------------------------------------------| -| Bytecode | 0x98 | -| Fee | 0.00000032 GAS | -| Function | Returns 1 if the inputs are not equal, 0 otherwise. | - -### Arithmetic Operation - -#### SIGN - -| Instruction | SIGN | -|----------|----------------------------------------------| -| Bytecode | 0x99 | -| Fee | 0.00000004 GAS | -| Function | Puts the sign of top stack item on top of the main stack. If value is negative, put -1; if positive, put 1; if value is zero, put 0. | - -#### ABS - -| Instruction | ABS | -|----------|--------------------------------| -| Bytecode | 0x9A | -| Fee | 0.00000004 GAS | -| Function | The input is made positive. | - -#### NEGATE - -| Instruction | NEGATE | -|----------|--------------------------------| -| Bytecode | 0x9B | -| Fee | 0.00000004 GAS | -| Function | The sign of the input is flipped. | - -#### INC - -| Instruction | INC | -|----------|------------------------------------| -| Bytecode | 0x9C | -| Fee | 0.00000004 GAS | -| Function | 1 is added to the input. | - -#### DEC - -| Instruction | DEC | -|----------|------------------------------------| -| Bytecode | 0x9D | -| Fee | 0.00000004 GAS | -| Function | 1 is subtracted from the input. | - -#### ADD - -| Instruction | ADD | -|----------|----------------------------------------| -| Bytecode | 0x9E | -| Fee | 0.00000008 GAS | -| Function | a is added to b. | - -#### SUB - -| Instruction | SUB | -|----------|----------------------------------------| -| Bytecode | 0x9F | -| Fee | 0.00000008 GAS | -| Function | b is subtracted from a. | - -#### MUL - -| Instruction | MUL | -|----------|----------------------------------------| -| Bytecode | 0xA0 | -| Fee | 0.00000008 GAS | -| Function | a is multiplied by b. | - -#### DIV - -| Instruction | DIV | -|----------|----------------------------------------| -| Bytecode | 0xA1 | -| Fee | 0.00000008 GAS | -| Function | a is divided by b. | - -#### MOD - -| Instruction | MOD | -|----------|----------------------------------------| -| Bytecode | 0xA2 | -| Fee | 0.00000008 GAS | -| Function | Returns the remainder after dividing a by b. | - -#### POW - -| Instruction | POW | -| ----------- | -------------------------------------------------- | -| Bytecode | 0xA3 | -| Fee | 0.00000064 GAS | -| Function | The result of raising value to the exponent power. | - -#### SQRT - -| Instruction | SQRT | -| ----------- | ---------------------------------------------- | -| Bytecode | 0xA4 | -| Fee | 0.00000064 GAS | -| Function | Returns the square root of a specified number. | - -#### SHL - -| Instruction | SHL | -|----------|----------------------------------| -| Bytecode | 0xA8 | -| Fee | 0.00000008 GAS | -| Function | Gets the integer n from the top stack and performs a n-bit left shift operation on the remaining BigInteger on the stack. | - -#### SHR - -| Instruction | SHR | -|----------|----------------------------------| -| Bytecode | 0xA9 | -| Fee | 0.00000008 GAS | -| Function | Gets the integer n from the top stack and performs a n-bit right shift operation on the remaining BigInteger on the stack. | - -#### NOT - -| Instruction | NOT | -|----------|------------------------------------| -| Bytecode | 0xAA | -| Fee | 0.00000004 GAS | -| Function | If the input is 0 or 1, it is flipped. Otherwise the output will be 0. | - -#### BOOLAND - -| Instruction | BOOLAND | -|----------|----------------------------------------| -| Bytecode | 0xAB | -| Fee | 0.00000008 GAS | -| Function | If both a and b are not 0, the output is 1. Otherwise 0. | - -#### BOOLOR - -| Instruction | BOOLOR | -|----------|----------------------------------------| -| Bytecode | 0xAC | -| Fee | 0.00000008 GAS | -| Function | If a or b is not 0, the output is 1. Otherwise 0. | - -#### NZ - -| Instruction | NZ | -|----------|-------------------------------------| -| Bytecode | 0xB1 | -| Fee | 0.00000004 GAS | -| Function | Returns 0 if the input is 0. 1 otherwise. | - -#### NUMEQUAL - -| Instruction | NUMEQUAL | -|----------|----------------------------------------| -| Bytecode | 0xB3 | -| Fee | 0.00000008 GAS | -| Function | Returns 1 if the numbers are equal, 0 otherwise. | - -#### NUMNOTEQUAL - -| Instruction | NUMNOTEQUAL | -|----------|------------------------------------------| -| Bytecode | 0xB4 | -| Fee | 0.00000008 GAS | -| Function | Returns 1 if the numbers are not equal, 0 otherwise.| - -#### LT - -| Instruction | LT | -|----------|----------------------------------------| -| Bytecode | 0xB5 | -| Fee | 0.00000008 GAS | -| Function | Returns 1 if a is less than b, 0 otherwise. | - -#### LE - -| Instruction | LE | -|----------|--------------------------------------------| -| Bytecode | 0xB6 | -| Fee | 0.00000008 GAS | -| Function | Returns 1 if a is less than or equal to b, 0 otherwise. | - -#### GT - -| Instruction | GT | -|----------|----------------------------------------| -| Bytecode | 0xB7 | -| Fee | 0.00000008 GAS | -| Function | Returns 1 if a is greater than b, 0 otherwise. | - -#### GE - -| Instruction | GE | -|----------|--------------------------------------------| -| Bytecode | 0xB8 | -| Fee | 0.00000008 GAS | -| Function | Returns 1 if a is greater than or equal to b, 0 otherwise. | - -#### MIN - -| Instruction | MIN | -|----------|----------------------------------------| -| Bytecode | 0xB9 | -| Fee | 0.00000008 GAS | -| Function | Returns the smaller of a and b. | - -#### MAX - -| Instruction | MAX | -|----------|----------------------------------------| -| Bytecode | 0xBA | -| Fee | 0.00000008 GAS | -| Function | Returns the larger of a and b. | - -#### WITHIN - -| Instruction | WITHIN | -|----------|----------------------------------------------| -| Bytecode | 0xBB | -| Fee | 0.00000008 GAS | -| Function | Returns 1 if x is within the specified range (left-inclusive), 0 otherwise. | - -### Advanced Data Structure - -It has implemented common operations for array, map, struct, etc. - -#### PACKMAP - -| Instruction | PACKMAP | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0xBE | -| Fee | 0.00002048 GAS | -| Function | A value n is taken from top of main stack. The next n*2 items on main stack are removed, put inside n-sized map and this map is put on top of the main stack. | - -#### PACKSTRUCT - -| Instruction | PACKSTRUCT | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0xBF | -| Fee | 0.00002048 GAS | -| Function | A value n is taken from top of main stack. The next n items on main stack are removed, put inside n-sized struct and this struct is put on top of the main stack. | - -#### PACK - -| Instruction | PACK | -|----------|-----------------------------------| -| Bytecode | 0xC0 | -| Fee | 0.00002048 GAS | -| Function | A value n is taken from top of main stack. The next n items on main stack are removed, put inside n-sized array and this array is put on top of the main stack. | - -#### UNPACK - -| Instruction | UNPACK | -|----------|------------------------------------| -| Bytecode | 0xC1 | -| Fee | 0.00002048 GAS | -| Function | An array is removed from top of the main stack. Its elements are put on top of the main stack (in reverse order) and the array size is also put on main stack. | - -#### NEWARRAY0 - -| Instruction | NEWARRAY0 | -|----------|------------------------------------| -| Bytecode | 0xC2 | -| Fee | 0.00000016 GAS | -| Function | An array with size n is put on top of the main stack. | - -#### NEWARRAY - -| Instruction | NEWARRAY | -|----------|------------------------------------| -| Bytecode | 0xC3 | -| Fee | 0.00000512 GAS | -| Function | A value n is taken from top of main stack. A null-filled array with size n is put on top of the main stack. | - -#### NEWARRAY_T - -| Instruction | NEWARRAY_T | -|----------|------------------------------------| -| Bytecode | 0xC4 | -| Fee | 0.00000512 GAS | -| Function | An array of type T with size n is put on top of the main stack. | - -#### NEWSTRUCT0 - -| Instruction | NEWSTRUCT0 | -|----------|------------------------------------| -| Bytecode | 0xC5 | -| Fee | 0.00000016 GAS | -| Function | A structure with size n and all 0 elements is put on top of the main stack. | - -#### NEWSTRUCT - -| Instruction | NEWSTRUCT | -|----------|------------------------------------| -| Bytecode | 0xC6 | -| Fee | 0.00000512 GAS | -| Function | A value n is taken from top of main stack. A zero-filled struct with size n is put on top of the main stack. | - -#### NEWMAP - -| Instruction | NEWMAP | -|----------|-------------------------| -| Bytecode | 0xC8 | -| Fee | 0.00000008 GAS | -| Function | An empty Map is put on top of the main stack. | - -#### SIZE - -| Instruction | SIZE | -|----------|-------------------------| -| Bytecode | 0xCA | -| Fee | 0.00000004 GAS | -| Function | Gets the size of elements on the top stack. | - -#### HASKEY - -| Instruction | HASKEY | -|----------|-------------------------| -| Bytecode | 0xCB | -| Fee | 0.00000064 GAS | -| Function | An input index n (or key) and an array (Map,Buffer, ByteString) are returned from the top of the main stack. Puts True on top of main stack if n is in the length range of the array (Map,Buffer, ByteString), and False otherwise. | - -#### KEYS - -| Instruction | KEYS | -|----------|-------------------------------------| -| Bytecode | 0xCC | -| Fee | 0.00000016 GAS | -| Function | Gets all Keys of the map from top of the main stack and constructs a new array with all Key and puts it on top of the main stack. | - -#### VALUES - -| Instruction | VALUES | -|----------|-----------------------------------------| -| Bytecode | 0xCD | -| Fee | 0.00008192 GAS | -| Function | Gets all Values of the elements (Array or Map) from top of the main stack and constructs a new array with all Value and puts it on top of the main stack.| - -#### PICKITEM - -| Instruction | PICKITEM | -|----------|------------------------------------| -| Bytecode | 0xCE | -| Fee | 0.00000064 GAS | -| Function | Gets the Nth element in the array of the top stack| - -#### APPEND - -| Instruction | APPEND | -|----------|-----------------------| -| Bytecode | 0xCF | -| Fee | 0.00008192 GAS | -| Function | Adds a new item to the arry of the top stack | - -#### SETITEM - -| Instruction | SETITEM | -|----------|------------------------------------------| -| Bytecode | 0xD0 | -| Fee | 0.00008192 GAS | -| Function | Assigns a value to the specified index of element (Array,Map or Buffer)in the top stack | - -#### REVERSEITEMS - -| Instruction | REVERSEITEMS | -|----------|------------------------------------------| -| Bytecode | 0xD1 | -| Fee | 0.00008192 GAS | -| Function | Reverses the elements in Array or Buffer from the top stack.| - -#### REMOVE - -| Instruction | REMOVE | -|----------|-----------------------------------| -| Bytecode | 0xD2 | -| Fee | 0.00000016 GAS | -| Function | Removes the specified index or Key elements from Array or Map | - -#### CLEARITEMS - -| Instruction | CLEARITEMS | -|----------|-----------------------------------------| -| Bytecode | 0xD3 | -| Fee | 0.00000016 GAS | -| Function | Remove all the items from the compound-type. | - -#### POPITEM - -| Instruction | POPITEM | -| ----------- | ------------------------------------------------------------ | -| Bytecode | 0xD4 | -| Fee | 0.00000016 GAS | -| Function | Pops the last element in Array from the stack top and push into the stack. | - -### Type - -#### ISNULL - -| Instruction | ISNULL | -|----------|-----------------------------------------| -| Bytecode | 0xD8 | -| Fee | 0.00000002 GAS | -| Function | Returns true if the input is null. Returns false otherwise. | - -#### ISTYPE - -| Instruction | ISTYPE | -|----------|-----------------------------------------| -| Bytecode | 0xD9 | -| Fee | 0.00000002 GAS | -| Function | Returns true if the top item is of the specified type.| - -#### CONVERT - -| Instruction | CONVERT | -|----------|-----------------------------------------| -| Bytecode | 0xDB | -| Fee | 0.00002048 GAS | -| Function | Converts the top item to the specified type. | - -:::note - -The operation code with \* indicates that the result of the operation is not pushed back to the `EvaluationStack` using `PUSH()`. -::: -