In this track: Inside the EVM
advanced · 4 MIN READ

The 256-bit stack

EVM stack items are full-width words with limited depth.

LET’S PICTURE IT

A pile of fixed-width cards exposes only its upper portion to common operations.

SEE IT FOR YOURSELF
Watch a stack machine execute a tiny programStep 1 / 4
Watch a stack machine execute a tiny programProgram→ PUSH1 0x02PUSH1 0x03ADD · STOPStackEmptyPC = 0A fixed local model; not a complete EVM implementationPUSH1 0x02Push immediate 2Next PC = 2Stack · top first2PUSH1 occupies one opcode byte plus one immediate bytePUSH1 0x03Push immediate 3Next PC = 4Stack · top first32The first value is below the most recently pushed valueADD3 + 2 = 5Next: STOP at PC 5Stack5No automatic SSTOREStack, memory and persistent storage are different locations

The program bytes are PUSH1 02, PUSH1 03, ADD, STOP. The program counter begins at byte zero.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

Use one word width

Each stack item is a 256-bit word. A small integer such as two still occupies one stack position rather than a special smaller stack item.

Read the top consistently

This site writes the stack bottom first and top last. Other references may show the top first, so check the convention before comparing traces.

Respect depth limits

The EVM stack has a maximum depth of 1024 items. Instructions can fail for too few operands or excessive stack growth.

Separate stack from persistent state

The stack is temporary execution state. Pushing an integer does not store it in a contract slot or expose it as a returned output.

Trace the idea

[]
PUSH1 0x02 → [2]
PUSH1 0x03 → [2, 3]
ADD → [5]

Stack examples list the bottom first and the top last. These small traces omit gas and surrounding dispatch unless stated.

QUICK CHECK · NO PRESSURE

How wide is an EVM stack item?

Your progress stays in this browser.
Keep exploring the original referenceethereum.org ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.