EIP-8120 · Draft · Core · 2026-01-07
EIP-8120: MLOAD8 and CALLDATALOAD8 Opcodes
Proposes two EVM opcodes, MLOAD8 and CALLDATALOAD8, that read a single byte from memory or calldata in one 3-gas step instead of a load-and-shift sequence.
What problem does it solve?
The EVM can store a single byte to memory (MSTORE8) but has no way to read just one byte. To get byte x of calldata today you load a full 32-byte word and shift it right:
PUSH x
CALLDATALOAD
PUSH1 248
SHR
That costs 9 gas (CALLDATALOAD + PUSH1 + SHR) and three extra bytes of bytecode every time. Contracts that parse compact, byte-oriented input, such as routers or mini-interpreters that treat calldata as a stream of commands, pay this overhead over and over.
How it works
Two new instructions, each taking one stack item (offset) and pushing one result:
| Opcode | Reads | Out-of-range behaviour | Gas |
|---|---|---|---|
MLOAD8 |
1 byte of memory at offset |
Memory expands to offset + 1 (like MSTORE8); new bytes are zero |
3 + memory expansion |
CALLDATALOAD8 |
1 byte of calldata at offset |
Returns 0 if offset >= CALLDATASIZE |
3 |
The byte is pushed as a 32-byte word with the value in the least significant position, so 0xab becomes 0x00…00ab. Running out of gas or stack underflow causes an exceptional halt, as with any other opcode.
Opcode numbers are not final. The authors suggest 0x4e for MLOAD8 and 0x4f for CALLDATALOAD8, because the 0x5X range is nearly full.
Replacing the three-instruction pattern with one CALLDATALOAD8 saves 6 gas and about 3 bytes of bytecode per byte read.
Sample code
Test vectors from the spec, written as pseudo-assembly:
; calldata = 0x0123456789abcdef
PUSH0
CALLDATALOAD8 ; stack: 0x01
; memory = 0xfedcba9876543210
PUSH1 0x02
MLOAD8 ; stack: 0xba
CALLDATALOAD8 ; empty stack -> exceptional halt
What the equivalent looks like in Solidity today (what the new opcode would replace):
function byteAt(uint256 i) internal pure returns (uint8 b) {
assembly {
b := shr(248, calldataload(i)) // CALLDATALOAD + PUSH1 + SHR
}
}
Things to know
- Status: Draft. Opcode values are tentative and may change during review.
- No existing instruction changes meaning, so there is no backwards-compatibility risk beyond that of adding any opcode in a hard fork.
- Compilers would need to learn the new opcodes before Solidity or Vyper code benefits automatically.
- For another recent example of a small, targeted arithmetic opcode, see EIP-7939 (
CLZ).