Skip to content
control flow

Control Flow

JUMP, JUMPI and JUMPDEST.

Execution usually flows line by line. JUMP and JUMPI allow the program to skip to different parts of the code. A JUMP takes the destination from the stack and moves the Program Counter (PC) there. For security, the destination MUST be a JUMPDEST (0x5b) instruction, or the execution will fail.

Execution Simulation

Assistant Note

"Currently at PUSH instruction. It's going to place a value on top of the stack."

Program

16 bytes
0000
PUSH10x0a
Place 1-byte item on stack
0002
PUSH10x01
0004
JUMPI
0005
PUSH10x00
0007
PUSH10x00
0009
REVERT
000a
JUMPDEST
000b
PUSH10x42
000d
PUSH10x00
000f
MSTORE

Stack

LIFO
0 / 1024
Stack is empty

Most opcodes pop their arguments from here.

Memory

0 bytes
00-0708-1516-2324-31
Memory is uninitialized
Memory is byte-addressable and volatile. It expands as you write to new offsets.

Gas Meter

Consumed0 / 1,000,000
Last Op Cost
-0
Refund
0
* Gas prevents infinite loops and DDoS. SSTORE is the most expensive opcode (20,000 gas for new slots).