Control flow must target a valid destination instruction.
LET’S PICTURE IT
A train can switch tracks only at marked junctions, not at arbitrary printed labels.
SEE IT FOR YOURSELF
Watch a stack machine execute a tiny programStep 1 / 4
The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.
The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.PUSH1 reads its next byte as an immediate value and places two on the stack. The next instruction begins at byte two.The next PUSH1 places three above two. Stack order matters for operations that are not commutative.ADD consumes the top two values and pushes five. The next instruction is STOP at byte five; no storage write is implied by ADD.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Read an unconditional jump
JUMP takes a destination from the stack and transfers control if that destination is valid. It does not interpret the destination as a source line number.
Read a conditional branch
JUMPI also checks a condition. A nonzero condition takes the jump, while a zero condition continues to the next instruction.
Validate the destination
The destination must be an actual JUMPDEST instruction in code. A byte equal to 0x5b inside PUSH immediate data is not automatically a valid destination.
Trace the chosen path
A program can contain instructions that are never reached for particular inputs. Follow conditions and destinations instead of counting every listed instruction as executed.
Trace the idea
PC 0: PUSH1 0x03
PC 2: JUMP
PC 3: JUMPDEST
PC 4: STOP
Stack examples list the bottom first and the top last. These small traces omit gas and surrounding dispatch unless stated.
QUICK CHECK · NO PRESSURE
Does 0x5b inside PUSH data automatically form a valid jump target?
Immediate data is not executed as a destination instruction.