ethereum.forks.spurious_dragon.vm.instructionsethereum.forks.byzantium.vm.instructions

EVM Instruction Encoding (Opcodes).

.. contents:: Table of Contents :backlinks: none :local:

Introduction

Machine readable representations of EVM instructions, and a mapping to their implementations.

Ops

Enum for EVM Opcodes.

class Ops:

ADD

38
    ADD = 0x01

MUL

39
    MUL = 0x02

SUB

40
    SUB = 0x03

DIV

41
    DIV = 0x04

SDIV

42
    SDIV = 0x05

MOD

43
    MOD = 0x06

SMOD

44
    SMOD = 0x07

ADDMOD

45
    ADDMOD = 0x08

MULMOD

46
    MULMOD = 0x09

EXP

47
    EXP = 0x0A

SIGNEXTEND

48
    SIGNEXTEND = 0x0B

LT

51
    LT = 0x10

GT

52
    GT = 0x11

SLT

53
    SLT = 0x12

SGT

54
    SGT = 0x13

EQ

55
    EQ = 0x14

ISZERO

56
    ISZERO = 0x15

AND

59
    AND = 0x16

OR

60
    OR = 0x17

XOR

61
    XOR = 0x18

NOT

62
    NOT = 0x19

BYTE

63
    BYTE = 0x1A

KECCAK

66
    KECCAK = 0x20

ADDRESS

69
    ADDRESS = 0x30

BALANCE

70
    BALANCE = 0x31

ORIGIN

71
    ORIGIN = 0x32

CALLER

72
    CALLER = 0x33

CALLVALUE

73
    CALLVALUE = 0x34

CALLDATALOAD

74
    CALLDATALOAD = 0x35

CALLDATASIZE

75
    CALLDATASIZE = 0x36

CALLDATACOPY

76
    CALLDATACOPY = 0x37

CODESIZE

77
    CODESIZE = 0x38

CODECOPY

78
    CODECOPY = 0x39

GASPRICE

79
    GASPRICE = 0x3A

EXTCODESIZE

80
    EXTCODESIZE = 0x3B

EXTCODECOPY

81
    EXTCODECOPY = 0x3C

RETURNDATASIZE

82
    RETURNDATASIZE = 0x3D

RETURNDATACOPY

83
    RETURNDATACOPY = 0x3E

BLOCKHASH

86
    BLOCKHASH = 0x40

COINBASE

87
    COINBASE = 0x41

TIMESTAMP

88
    TIMESTAMP = 0x42

NUMBER

89
    NUMBER = 0x43

DIFFICULTY

90
    DIFFICULTY = 0x44

GASLIMIT

91
    GASLIMIT = 0x45

STOP

94
    STOP = 0x00

JUMP

95
    JUMP = 0x56

JUMPI

96
    JUMPI = 0x57

PC

97
    PC = 0x58

GAS

98
    GAS = 0x5A

JUMPDEST

99
    JUMPDEST = 0x5B

SLOAD

102
    SLOAD = 0x54

SSTORE

103
    SSTORE = 0x55

POP

106
    POP = 0x50

PUSH1

109
    PUSH1 = 0x60

PUSH2

110
    PUSH2 = 0x61

PUSH3

111
    PUSH3 = 0x62

PUSH4

112
    PUSH4 = 0x63

PUSH5

113
    PUSH5 = 0x64

PUSH6

114
    PUSH6 = 0x65

PUSH7

115
    PUSH7 = 0x66

PUSH8

116
    PUSH8 = 0x67

PUSH9

117
    PUSH9 = 0x68

PUSH10

118
    PUSH10 = 0x69

PUSH11

119
    PUSH11 = 0x6A

PUSH12

120
    PUSH12 = 0x6B

PUSH13

121
    PUSH13 = 0x6C

PUSH14

122
    PUSH14 = 0x6D

PUSH15

123
    PUSH15 = 0x6E

PUSH16

124
    PUSH16 = 0x6F

PUSH17

125
    PUSH17 = 0x70

PUSH18

126
    PUSH18 = 0x71

PUSH19

127
    PUSH19 = 0x72

PUSH20

128
    PUSH20 = 0x73

PUSH21

129
    PUSH21 = 0x74

PUSH22

130
    PUSH22 = 0x75

PUSH23

131
    PUSH23 = 0x76

PUSH24

132
    PUSH24 = 0x77

PUSH25

133
    PUSH25 = 0x78

PUSH26

134
    PUSH26 = 0x79

PUSH27

135
    PUSH27 = 0x7A

PUSH28

136
    PUSH28 = 0x7B

PUSH29

137
    PUSH29 = 0x7C

PUSH30

138
    PUSH30 = 0x7D

PUSH31

139
    PUSH31 = 0x7E

PUSH32

140
    PUSH32 = 0x7F

DUP1

143
    DUP1 = 0x80

DUP2

144
    DUP2 = 0x81

DUP3

145
    DUP3 = 0x82

DUP4

146
    DUP4 = 0x83

DUP5

147
    DUP5 = 0x84

DUP6

148
    DUP6 = 0x85

DUP7

149
    DUP7 = 0x86

DUP8

150
    DUP8 = 0x87

DUP9

151
    DUP9 = 0x88

DUP10

152
    DUP10 = 0x89

DUP11

153
    DUP11 = 0x8A

DUP12

154
    DUP12 = 0x8B

DUP13

155
    DUP13 = 0x8C

DUP14

156
    DUP14 = 0x8D

DUP15

157
    DUP15 = 0x8E

DUP16

158
    DUP16 = 0x8F

SWAP1

161
    SWAP1 = 0x90

SWAP2

162
    SWAP2 = 0x91

SWAP3

163
    SWAP3 = 0x92

SWAP4

164
    SWAP4 = 0x93

SWAP5

165
    SWAP5 = 0x94

SWAP6

166
    SWAP6 = 0x95

SWAP7

167
    SWAP7 = 0x96

SWAP8

168
    SWAP8 = 0x97

SWAP9

169
    SWAP9 = 0x98

SWAP10

170
    SWAP10 = 0x99

SWAP11

171
    SWAP11 = 0x9A

SWAP12

172
    SWAP12 = 0x9B

SWAP13

173
    SWAP13 = 0x9C

SWAP14

174
    SWAP14 = 0x9D

SWAP15

175
    SWAP15 = 0x9E

SWAP16

176
    SWAP16 = 0x9F

MLOAD

179
    MLOAD = 0x51

MSTORE

180
    MSTORE = 0x52

MSTORE8

181
    MSTORE8 = 0x53

MSIZE

182
    MSIZE = 0x59

LOG0

185
    LOG0 = 0xA0

LOG1

186
    LOG1 = 0xA1

LOG2

187
    LOG2 = 0xA2

LOG3

188
    LOG3 = 0xA3

LOG4

189
    LOG4 = 0xA4

CREATE

192
    CREATE = 0xF0

CALL

193
    CALL = 0xF1

CALLCODE

194
    CALLCODE = 0xF2

RETURN

195
    RETURN = 0xF3

DELEGATECALL

196
    DELEGATECALL = 0xF4

STATICCALL

197
    STATICCALL = 0xFA

REVERT

198
    REVERT = 0xFD

SELFDESTRUCT

199
    SELFDESTRUCT = 0xFF

op_implementation

202
op_implementation: Dict[Ops, Callable] = {
203
    Ops.STOP: control_flow_instructions.stop,
204
    Ops.ADD: arithmetic_instructions.add,
205
    Ops.MUL: arithmetic_instructions.mul,
206
    Ops.SUB: arithmetic_instructions.sub,
207
    Ops.DIV: arithmetic_instructions.div,
208
    Ops.SDIV: arithmetic_instructions.sdiv,
209
    Ops.MOD: arithmetic_instructions.mod,
210
    Ops.SMOD: arithmetic_instructions.smod,
211
    Ops.ADDMOD: arithmetic_instructions.addmod,
212
    Ops.MULMOD: arithmetic_instructions.mulmod,
213
    Ops.EXP: arithmetic_instructions.exp,
214
    Ops.SIGNEXTEND: arithmetic_instructions.signextend,
215
    Ops.LT: comparison_instructions.less_than,
216
    Ops.GT: comparison_instructions.greater_than,
217
    Ops.SLT: comparison_instructions.signed_less_than,
218
    Ops.SGT: comparison_instructions.signed_greater_than,
219
    Ops.EQ: comparison_instructions.equal,
220
    Ops.ISZERO: comparison_instructions.is_zero,
221
    Ops.AND: bitwise_instructions.bitwise_and,
222
    Ops.OR: bitwise_instructions.bitwise_or,
223
    Ops.XOR: bitwise_instructions.bitwise_xor,
224
    Ops.NOT: bitwise_instructions.bitwise_not,
225
    Ops.BYTE: bitwise_instructions.get_byte,
226
    Ops.KECCAK: keccak_instructions.keccak,
227
    Ops.SLOAD: storage_instructions.sload,
228
    Ops.BLOCKHASH: block_instructions.block_hash,
229
    Ops.COINBASE: block_instructions.coinbase,
230
    Ops.TIMESTAMP: block_instructions.timestamp,
231
    Ops.NUMBER: block_instructions.number,
232
    Ops.DIFFICULTY: block_instructions.difficulty,
233
    Ops.GASLIMIT: block_instructions.gas_limit,
234
    Ops.MLOAD: memory_instructions.mload,
235
    Ops.MSTORE: memory_instructions.mstore,
236
    Ops.MSTORE8: memory_instructions.mstore8,
237
    Ops.MSIZE: memory_instructions.msize,
238
    Ops.ADDRESS: environment_instructions.address,
239
    Ops.BALANCE: environment_instructions.balance,
240
    Ops.ORIGIN: environment_instructions.origin,
241
    Ops.CALLER: environment_instructions.caller,
242
    Ops.CALLVALUE: environment_instructions.callvalue,
243
    Ops.CALLDATALOAD: environment_instructions.calldataload,
244
    Ops.CALLDATASIZE: environment_instructions.calldatasize,
245
    Ops.CALLDATACOPY: environment_instructions.calldatacopy,
246
    Ops.CODESIZE: environment_instructions.codesize,
247
    Ops.CODECOPY: environment_instructions.codecopy,
248
    Ops.GASPRICE: environment_instructions.gasprice,
249
    Ops.EXTCODESIZE: environment_instructions.extcodesize,
250
    Ops.EXTCODECOPY: environment_instructions.extcodecopy,
251
    Ops.RETURNDATASIZE: environment_instructions.returndatasize,
252
    Ops.RETURNDATACOPY: environment_instructions.returndatacopy,
253
    Ops.SSTORE: storage_instructions.sstore,
254
    Ops.JUMP: control_flow_instructions.jump,
255
    Ops.JUMPI: control_flow_instructions.jumpi,
256
    Ops.PC: control_flow_instructions.pc,
257
    Ops.GAS: control_flow_instructions.gas_left,
258
    Ops.JUMPDEST: control_flow_instructions.jumpdest,
259
    Ops.POP: stack_instructions.pop,
260
    Ops.PUSH1: stack_instructions.push1,
261
    Ops.PUSH2: stack_instructions.push2,
262
    Ops.PUSH3: stack_instructions.push3,
263
    Ops.PUSH4: stack_instructions.push4,
264
    Ops.PUSH5: stack_instructions.push5,
265
    Ops.PUSH6: stack_instructions.push6,
266
    Ops.PUSH7: stack_instructions.push7,
267
    Ops.PUSH8: stack_instructions.push8,
268
    Ops.PUSH9: stack_instructions.push9,
269
    Ops.PUSH10: stack_instructions.push10,
270
    Ops.PUSH11: stack_instructions.push11,
271
    Ops.PUSH12: stack_instructions.push12,
272
    Ops.PUSH13: stack_instructions.push13,
273
    Ops.PUSH14: stack_instructions.push14,
274
    Ops.PUSH15: stack_instructions.push15,
275
    Ops.PUSH16: stack_instructions.push16,
276
    Ops.PUSH17: stack_instructions.push17,
277
    Ops.PUSH18: stack_instructions.push18,
278
    Ops.PUSH19: stack_instructions.push19,
279
    Ops.PUSH20: stack_instructions.push20,
280
    Ops.PUSH21: stack_instructions.push21,
281
    Ops.PUSH22: stack_instructions.push22,
282
    Ops.PUSH23: stack_instructions.push23,
283
    Ops.PUSH24: stack_instructions.push24,
284
    Ops.PUSH25: stack_instructions.push25,
285
    Ops.PUSH26: stack_instructions.push26,
286
    Ops.PUSH27: stack_instructions.push27,
287
    Ops.PUSH28: stack_instructions.push28,
288
    Ops.PUSH29: stack_instructions.push29,
289
    Ops.PUSH30: stack_instructions.push30,
290
    Ops.PUSH31: stack_instructions.push31,
291
    Ops.PUSH32: stack_instructions.push32,
292
    Ops.DUP1: stack_instructions.dup1,
293
    Ops.DUP2: stack_instructions.dup2,
294
    Ops.DUP3: stack_instructions.dup3,
295
    Ops.DUP4: stack_instructions.dup4,
296
    Ops.DUP5: stack_instructions.dup5,
297
    Ops.DUP6: stack_instructions.dup6,
298
    Ops.DUP7: stack_instructions.dup7,
299
    Ops.DUP8: stack_instructions.dup8,
300
    Ops.DUP9: stack_instructions.dup9,
301
    Ops.DUP10: stack_instructions.dup10,
302
    Ops.DUP11: stack_instructions.dup11,
303
    Ops.DUP12: stack_instructions.dup12,
304
    Ops.DUP13: stack_instructions.dup13,
305
    Ops.DUP14: stack_instructions.dup14,
306
    Ops.DUP15: stack_instructions.dup15,
307
    Ops.DUP16: stack_instructions.dup16,
308
    Ops.SWAP1: stack_instructions.swap1,
309
    Ops.SWAP2: stack_instructions.swap2,
310
    Ops.SWAP3: stack_instructions.swap3,
311
    Ops.SWAP4: stack_instructions.swap4,
312
    Ops.SWAP5: stack_instructions.swap5,
313
    Ops.SWAP6: stack_instructions.swap6,
314
    Ops.SWAP7: stack_instructions.swap7,
315
    Ops.SWAP8: stack_instructions.swap8,
316
    Ops.SWAP9: stack_instructions.swap9,
317
    Ops.SWAP10: stack_instructions.swap10,
318
    Ops.SWAP11: stack_instructions.swap11,
319
    Ops.SWAP12: stack_instructions.swap12,
320
    Ops.SWAP13: stack_instructions.swap13,
321
    Ops.SWAP14: stack_instructions.swap14,
322
    Ops.SWAP15: stack_instructions.swap15,
323
    Ops.SWAP16: stack_instructions.swap16,
324
    Ops.LOG0: log_instructions.log0,
325
    Ops.LOG1: log_instructions.log1,
326
    Ops.LOG2: log_instructions.log2,
327
    Ops.LOG3: log_instructions.log3,
328
    Ops.LOG4: log_instructions.log4,
329
    Ops.CREATE: system_instructions.create,
330
    Ops.RETURN: system_instructions.return_,
331
    Ops.CALL: system_instructions.call,
332
    Ops.CALLCODE: system_instructions.callcode,
333
    Ops.DELEGATECALL: system_instructions.delegatecall,
328
    Ops.SELFDESTRUCT: system_instructions.selfdestruct,
334
    Ops.SELFDESTRUCT: system_instructions.selfdestruct,
335
    Ops.STATICCALL: system_instructions.staticcall,
336
    Ops.REVERT: system_instructions.revert,
337
}