Overview
Opcode:0x85
Introduced: Frontier (EVM genesis)
DUP6 duplicates the 6th stack item and pushes it to the top of the stack. The original 6th item remains in place.
Specification
Stack Input:Behavior
DUP6 copies the 6th-from-top stack item without removing it. Requires stack depth ≥ 6. Key characteristics:- Requires stack depth ≥ 6
- Original value unchanged
- New copy pushed to top
- StackUnderflow if depth < 6
- Stack depth increases by 1
Examples
Basic Usage
Solidity Compilation
Assembly Usage
Gas Cost
Cost: 3 gas (GasFastestStep) All DUP1-16 operations cost the same despite different stack depths accessed. Comparison:| Operation | Gas | Note |
|---|---|---|
| DUP6 | 3 | Duplicate 6th item |
| PUSH1-32 | 3 | Same cost tier |
| POP | 2 | Cheaper |
Common Usage
Deep Stack Access
Conditional Logic
Stack Depth Requirements
Minimum Depth
Safe Usage
Implementation
- TypeScript
Edge Cases
Stack Underflow
Stack Overflow
Out of Gas
Maximum Value
References
- Yellow Paper - Section 9.1 (Stack Operations)
- EVM Codes - DUP6
- Solidity Assembly - dup6

