Categories
2. Ethereum virtual machine

Opcodes

Under the hood, the EVM uses a set of instructions (called opcodes) to execute specific tasks. At the time of writing, there are 140 unique opcodes. Together, these opcodes allow the EVM to be Turing-complete. This means the EVM is able to compute (almost) anything, given enough resources. Because opcodes are 1 byte, there can only be a maximum of 256 (16²) opcodes. For simplicity’s sake, we can split all opcodes into the following categories:

  • Stack-manipulating opcodes (POP, PUSH, DUP, SWAP)
  • Arithmetic/comparison/bitwise opcodes (ADD, SUB, GT, LT, AND, OR)
  • Environmental opcodes (CALLER, CALLVALUE, NUMBER)
  • Memory-manipulating opcodes (MLOAD, MSTORE, MSTORE8, MSIZE)
  • Storage-manipulating opcodes (SLOAD, SSTORE)
  • Program counter related opcodes (JUMP, JUMPI, PC, JUMPDEST)
  • Halting opcodes (STOP, RETURN, REVERT, INVALID, SELFDESTRUCT)

Leave a Reply

Your email address will not be published. Required fields are marked *