Skip to content
stack

Stack Machine Model

Understanding the LIFO architecture.

The EVM uses a Last-In, First-Out (LIFO) stack to store small pieces of data needed for operations. The stack can hold up to 1024 items, each 256 bits wide. Most opcodes work by popping one or more items from the top, performing a calculation, and pushing the result back. For example, ADD pops two numbers and pushes their sum.

Execution Simulation

Assistant Note

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

Program

5 bytes
0000
PUSH10x01
Place 1-byte item on stack
0002
PUSH10x02
0004
ADD

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).