Ethereum  PoC-8
The C++ Implementation of Ethereum
Instruction.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #pragma once
19 
20 #include <cstdint>
21 
22 namespace dev
23 {
24 namespace eth
25 {
26 
28 enum class Instruction : uint8_t
29 {
30  STOP = 0x00,
31  ADD,
32  MUL,
33  SUB,
34  DIV,
35  SDIV,
36  MOD,
37  SMOD,
38  ADDMOD,
39  MULMOD,
40  EXP,
41  SIGNEXTEND,
42 
43  LT = 0x10,
44  GT,
45  SLT,
46  SGT,
47  EQ,
48  ISZERO,
49  AND,
50  OR,
51  XOR,
52  NOT,
53  BYTE,
54  SHL,
55  SHR,
56  SAR,
57 
58  SHA3 = 0x20,
59 
60  ADDRESS = 0x30,
61  BALANCE,
62  ORIGIN,
63  CALLER,
64  CALLVALUE,
65  CALLDATALOAD,
67  CALLDATASIZE,
68  CALLDATACOPY,
69  CODESIZE,
70  CODECOPY,
71  GASPRICE,
72  EXTCODESIZE,
73  EXTCODECOPY,
74  RETURNDATASIZE = 0x3d,
75  RETURNDATACOPY = 0x3e,
76  EXTCODEHASH = 0x3f,
77 
78  BLOCKHASH = 0x40,
79  COINBASE,
80  TIMESTAMP,
81  NUMBER,
82  DIFFICULTY,
83  GASLIMIT,
84 
85  POP = 0x50,
86  MLOAD,
87  MSTORE,
88  MSTORE8,
89  SLOAD,
90  SSTORE,
91  JUMP,
92  JUMPI,
93  PC,
94  MSIZE,
95  GAS,
96  JUMPDEST,
97 
98  PUSH1 = 0x60,
99  PUSH2,
100  PUSH3,
101  PUSH4,
102  PUSH5,
103  PUSH6,
104  PUSH7,
105  PUSH8,
106  PUSH9,
107  PUSH10,
108  PUSH11,
109  PUSH12,
110  PUSH13,
111  PUSH14,
112  PUSH15,
113  PUSH16,
114  PUSH17,
115  PUSH18,
116  PUSH19,
117  PUSH20,
118  PUSH21,
119  PUSH22,
120  PUSH23,
121  PUSH24,
122  PUSH25,
123  PUSH26,
124  PUSH27,
125  PUSH28,
126  PUSH29,
127  PUSH30,
128  PUSH31,
129  PUSH32,
130 
131  DUP1 = 0x80,
132  DUP2,
133  DUP3,
134  DUP4,
135  DUP5,
136  DUP6,
137  DUP7,
138  DUP8,
139  DUP9,
140  DUP10,
141  DUP11,
142  DUP12,
143  DUP13,
144  DUP14,
145  DUP15,
146  DUP16,
147 
148  SWAP1 = 0x90,
149  SWAP2,
150  SWAP3,
151  SWAP4,
152  SWAP5,
153  SWAP6,
154  SWAP7,
155  SWAP8,
156  SWAP9,
157  SWAP10,
158  SWAP11,
159  SWAP12,
160  SWAP13,
161  SWAP14,
162  SWAP15,
163  SWAP16,
164 
165  LOG0 = 0xa0,
166  LOG1,
167  LOG2,
168  LOG3,
169  LOG4,
170 
171  // these are generated by the interpreter - should never be in user code
172  PUSHC = 0xac,
173  JUMPC,
174  JUMPCI,
175 
176  JUMPTO = 0xb0,
177  JUMPIF,
178  JUMPSUB,
179  JUMPV,
180  JUMPSUBV,
181  BEGINSUB,
182  BEGINDATA,
183  RETURNSUB,
184  PUTLOCAL,
185  GETLOCAL,
186 
187  XADD = 0xc1,
188  XMUL,
189  XSUB,
190  XDIV,
191  XSDIV,
192  XMOD,
193  XSMOD,
194  XLT = 0xd0,
195  XGT,
196  XSLT,
197  XSGT,
198  XEQ,
199  XISZERO,
200  XAND,
201  XOOR,
202  XXOR,
203  XNOT,
204  XSHL = 0xdb,
205  XSHR,
206  XSAR,
207  XROL,
208  XROR,
209  XPUSH = 0xe0,
210  XMLOAD,
211  XMSTORE,
212  XSLOAD = 0xe4,
213  XSSTORE,
214  XVTOWIDE,
215  XWIDETOV,
216  XGET,
217  XPUT,
218  XSWIZZLE,
219  XSHUFFLE,
220 
221  CREATE = 0xf0,
222  CALL,
223  CALLCODE,
224  RETURN,
225  DELEGATECALL,
226  CREATE2 = 0xf5,
227  STATICCALL = 0xfa,
228  REVERT = 0xfd,
230  INVALID = 0xfe,
231  SUICIDE = 0xff
232 };
233 
234 enum class Tier : unsigned
235 {
236  Zero = 0, // 0, Zero
237  Base, // 2, Quick
238  VeryLow, // 3, Fastest
239  Low, // 5, Fast
240  Mid, // 8, Mid
241  High, // 10, Slow
242  Ext, // 20, Ext
243  Special, // multiparam or otherwise special
244  Invalid // Invalid.
245 };
246 
249 {
250  char const* const name;
251  int const args;
252  int const ret;
254 };
255 
257 {
259  int args;
260  int ret;
261 };
262 
265 
266 }
267 }
signed greater-than comparision
set a potential jumpsub destination
bitwise XOR operation
place 17 byte item on stack
bitwise OR operation
Definition: Address.cpp:20
exponential operation
unsigned modular addition
place 10 byte item on stack
copies the 14th highest item in the stack to the top of the stack
get external code size (from another contract)
place 28 byte item on stack
return to subroutine jumped from
place 19 byte item on stack
unsigned modular multiplication
get the block&#39;s timestamp
place 1 byte item on stack
modulo remainder operation
place 27 byte item on stack
place 31 byte item on stack
dedicated invalid instruction
conditionally alter the program counter
place 13 byte item on stack
char const *const name
The name of the instruction.
Definition: Instruction.h:250
convert vector to wide integer
alter the program counter to a beginsub
copy input data in current environment to memory
conditionally alter the program counter
place 2 byte item on stack
addition operation
retrieve single byte from word
get external code hash
shift arithmetic right opertation
arithmetic shift right operation
place 6 byte item on stack
place 20 byte item on stack
load vector from storage
signed modulo remainder operation
swaps the highest and 6th highest value on the stack
swaps the highest and 9th highest value on the stack
get execution origination address
shift left opertation
create a new account with associated code. sha3((sender + salt + code)
Makes a log entry; 4 topics.
get the block&#39;s number
swaps the highest and 15th highest value on the stack
equality comparision
swaps the highest and 11th highest value on the stack
swaps the highest and 13th highest value on the stack
integer division operation
copies the 9th highest item in the stack to the top of the stack
swaps the highest and 17th highest value on the stack
get the block&#39;s coinbase address
simple not operator
set a potential jump destination
push local variable to top of stack
swaps the highest and 7th highest value on the stack
get input data of current environment
signed less-than comparision
bitwise OR operation
place 30 byte item on stack
place 12 byte item on stack
save byte to memory
greater-than comparision
addition operation
copies the 5th highest item in the stack to the top of the stack
halt execution and register account for later deletion
place 8 byte item on stack
swaps the highest and third highest value on the stack
signed integer division operation
load word from storage
swaps the highest and 4th highest value on the stack
save vector to memory
copies the 16th highest item in the stack to the top of the stack
int const args
Number of items required on the stack for this instruction (and, for the purposes of ret...
Definition: Instruction.h:251
place 29 byte item on stack
signed less-than comparision
InstructionInfo instructionInfo(Instruction _inst)
Information on all the instructions.
halt execution returning output data
conditionally alter the program counter - pre-verified
copies the 10th highest item in the stack to the top of the stack
get address of currently executing account
int const ret
Number of items placed (back) on the stack by this instruction, assuming args items were removed...
Definition: Instruction.h:252
place 25 byte item on stack
place 26 byte item on stack
remove item from stack
get hash of most recent complete block
alter the program counter - pre-verified
get the program counter
copies the 6th highest item in the stack to the top of the stack
copies the third highest item in the stack to the top of the stack
swaps the highest and 14th highest value on the stack
greater-than comparision
get size of code running in current environment
rotate right opertation
place 16 byte item on stack
copies the highest item in the stack to the top of the stack
Makes a log entry; no topics.
get the size of active memory
copies the 8th highest item in the stack to the top of the stack
copies the second highest item in the stack to the top of the stack
get the block&#39;s gas limit
place 3 byte item on stack
copy data returned from previous call to memory
place 11 byte item on stack
get balance of the given account
save word to storage
message-call with another account&#39;s code only
less-than comparision
load vector from memory
equality comparision
permute data in two vectors
compute SHA3-256 hash
get size of input data in current environment
extend length of signed integer
permute data in vector
place 18 byte item on stack
Tier const gasPriceTier
Tier for gas pricing.
Definition: Instruction.h:253
copy code running in current environment to memory
logical shift left operation
place 15 byte item on stack
bitwise AND operation
copies the 11th highest item in the stack to the top of the stack
signed modulo remainder operation
subtraction operation
mulitplication operation
swaps the highest and 10th highest value on the stack
swaps the highest and 5th highest value on the stack
like CALLCODE but keeps caller&#39;s value and sender
swaps the highest and 16th highest value on the stack
place 23 byte item on stack
size of data returned from previous call
Instruction
Virtual machine bytecode instruction.
Definition: Instruction.h:28
get the amount of available gas
swaps the highest and 12th highest value on the stack
bitwise AND operation
copies the 4th highest item in the stack to the top of the stack
put data in vector
get data from vector
copy external code (from another contract)
alter the program counter to a beginsub
Information structure for a particular instruction.
Definition: Instruction.h:248
signed greater-than comparision
swaps the highest and 8th highest value on the stack
integer division operation
place 32 byte item on stack
place 22 byte item on stack
place 9 byte item on stack
get price of gas in current environment
logical shift right operation
alter the program counter to a jumpdest
swaps the highest and second highest value on the stack
convert wide integer to vector
Makes a log entry; 1 topic.
bitwise XOR operation
copies the 15th highest item in the stack to the top of the stack
place 14 byte item on stack
push vector to stack
message-call into an account
pop top of stack to local variable
get the block&#39;s difficulty
rotate left opertation
save word to memory
alter the program counter to a jumpdest
shift right opertation
stop execution and revert state changes, without consuming all provided gas
place 24 byte item on stack
place 7 byte item on stack
bitwise NOT opertation
save vector to storage
Makes a log entry; 3 topics.
less-than comparision
signed integer division operation
alter the program counter to a jumpdest
push value from constant pool
place 5 byte item on stack
copies the 12th highest item in the stack to the top of the stack
copies the 7th highest item in the stack to the top of the stack
begine the data section
load word from memory
subtraction operation
simple not operator
place 4 byte item on stack
bitwise NOT operation
modulo remainder operation
copies the 13th highest item in the stack to the top of the stack
place 21 byte item on stack
mulitplication operation
create a new account with associated code
Makes a log entry; 2 topics.