Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 683a100

Browse files
authored
add POW, SQRT, PACKMAP, PACKSTRUCT; fix GAS price for PACK, UNPACK (#1350)
1 parent dccd731 commit 683a100

File tree

2 files changed

+68
-4
lines changed

2 files changed

+68
-4
lines changed

docs/en-us/reference/neo_vm.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,22 @@ Copy, remove and swap the elements of the stack.
777777
| Fee | 0.00000008 GAS |
778778
| Function | Returns the remainder after dividing a by b. |
779779

780+
#### POW
781+
782+
| Instruction | POW |
783+
| ----------- | -------------------------------------------------- |
784+
| Bytecode | 0xA3 |
785+
| Fee | 0.00000064 GAS |
786+
| Function | The result of raising value to the exponent power. |
787+
788+
#### SQRT
789+
790+
| Instruction | SQRT |
791+
| ----------- | ---------------------------------------------- |
792+
| Bytecode | 0xA4 |
793+
| Fee | 0.00000064 GAS |
794+
| Function | Returns the square root of a specified number. |
795+
780796
#### SHL
781797

782798
| Instruction | SHL |
@@ -903,20 +919,36 @@ Copy, remove and swap the elements of the stack.
903919

904920
It has implemented common operations for array, map, struct, etc.
905921

922+
#### PACKMAP
923+
924+
| Instruction | PACKMAP |
925+
| ----------- | ------------------------------------------------------------ |
926+
| Bytecode | 0xBE |
927+
| Fee | 0.00002048 GAS |
928+
| 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. |
929+
930+
#### PACKSTRUCT
931+
932+
| Instruction | PACKSTRUCT |
933+
| ----------- | ------------------------------------------------------------ |
934+
| Bytecode | 0xBF |
935+
| Fee | 0.00002048 GAS |
936+
| 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. |
937+
906938
#### PACK
907939

908940
| Instruction | PACK |
909941
|----------|-----------------------------------|
910942
| Bytecode | 0xC0 |
911-
| Fee | 0.00000512 GAS |
943+
| Fee | 0.00002048 GAS |
912944
| 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. |
913945

914946
#### UNPACK
915947

916948
| Instruction | UNPACK |
917949
|----------|------------------------------------|
918950
| Bytecode | 0xC1 |
919-
| Fee | 0.00000512 GAS |
951+
| Fee | 0.00002048 GAS |
920952
| 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. |
921953

922954
#### NEWARRAY0

docs/zh-cn/reference/neo_vm.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,22 @@ NeoVM虚拟机一共实现了189个指令,类别如下
776776
| 系统费 | 0.00000008 GAS |
777777
| 功能 | 用计算栈第二个BigInteger除以第一个BigInteger取余。 |
778778

779+
#### POW
780+
781+
| 指令 | POW |
782+
| ------ | ------------------------------------------------------------ |
783+
| 字节码 | 0xA3 |
784+
| 系统费 | 0.00000064 GAS |
785+
| 功能 | 用计算栈第二个BigInteger为底数,第一个integer为指数,求乘方。 |
786+
787+
#### SQRT
788+
789+
| 指令 | SQRT |
790+
| ------ | ------------------------------------------------------------ |
791+
| 字节码 | 0xA4 |
792+
| 系统费 | 0.00000064 GAS |
793+
| 功能 | 求计算栈第一个非负BigInteger的开方,并向下取整为BigInteger。 |
794+
779795
#### SHL
780796

781797
| 指令 | SHL |
@@ -899,20 +915,36 @@ NeoVM虚拟机一共实现了189个指令,类别如下
899915
### 高级数据结构
900916
实现对Array、Map、Struct等的常用操作。
901917

918+
#### PACKMAP
919+
920+
| 指令 | PACKMAP |
921+
| ------ | ------------------------------------------------------------ |
922+
| 字节码 | 0xBE |
923+
| 系统费 | 0.00002048 GAS |
924+
| 功能 | 将计算栈栈顶的2n个元素打包成Map。第1个为key,第2个为第1个的value。 |
925+
926+
#### PACKSTRUCT
927+
928+
| 指令 | PACKSTRUCT |
929+
| ------ | ----------------------------------- |
930+
| 字节码 | 0xBF |
931+
| 系统费 | 0.00002048 GAS |
932+
| 功能 | 将计算栈栈顶的n个元素打包成结构体。 |
933+
902934
#### PACK
903935

904936
| 指令 | PACK |
905937
| ------ | --------------------------------- |
906938
| 字节码 | 0xC0 |
907-
| 系统费 | 0.00000512 GAS |
939+
| 系统费 | 0.00002048 GAS |
908940
| 功能 | 将计算栈栈顶的n个元素打包成数组。 |
909941

910942
#### UNPACK
911943

912944
| 指令 | UNPACK |
913945
| ------ | ---------------------------------- |
914946
| 字节码 | 0xC1 |
915-
| 系统费 | 0.00000512 GAS |
947+
| 系统费 | 0.00002048 GAS |
916948
| 功能 | 将计算栈栈顶的数组拆包成元素序列。 |
917949

918950
#### NEWARRAY0

0 commit comments

Comments
 (0)