---
eip: 7961
label: EIP-7961
title: EVM64 - EOF code section
status: Draft
type: Standards Track
category: Core
created: 2025-05-28
requires: 3540, 4750, 7960
official: https://eips.ethereum.org/EIPS/eip-7961
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7961.md
canonical: https://eips.huatuo.xyz/eip-7961/
lang: en
tldr: "Defines a new EOF code-section type in which every instruction operates on 64-bit values, giving cheaper, smaller code for arithmetic that doesn't need 256 bits."
tags: [evm, eof, evm64, performance, opcodes]
---

# EIP-7961: EVM64 - EOF code section

> Define "pure" EVM64 mode, as an EOF code section.

**TL;DR:** Defines a new EOF code-section type in which every instruction operates on 64-bit values, giving cheaper, smaller code for arithmetic that doesn't need 256 bits.

## What problem does it solve?

Every EVM stack item is 256 bits wide, even when a program only needs counters, indices or small integers. Real CPUs work natively in 64 bits, so interpreters pay for wide arithmetic they rarely need, and gas prices reflect that.

The "EVM64" series proposes 64-bit execution. [EIP-7937](/eip-7937/) does it with prefixed opcodes usable from legacy code. EIP-7961 is the alternative: mark an entire **EOF code section** as EVM64, so ordinary one-byte opcodes take on 64-bit meaning inside it.

## How it works

- Using the extended types section from [EIP-7960](/eip-7960/), a code section can declare type `0x02` = EVM64.
- When execution enters such a section (at the start of a call or via `CALLF`), the interpreter is in "pure EVM64 mode". EOF validation ensures only allowed opcodes appear there.
- All allowed opcodes read only the **least significant 64 bits** of each stack item and compute modulo 2^64. The stack is formally still 256-bit, but the upper bits become unobservable, so clients can use a 64-bit stack internally.

What is allowed, and the new gas costs:

| Group | Opcodes | Notes |
| --- | --- | --- |
| Arithmetic | `ADD`, `SUB`, `MUL`, `DIV`, `MOD`, `ADDMOD`, `EXP`… | mod 2^64; 2–5 gas, `EXP` 5 + 25 per exponent byte |
| Compare / bitwise | `LT`…`SAR` | 2 gas; `BYTE` becomes little-endian |
| Memory | `MLOAD64` (`0x51`), `MSTORE64` (`0x52`), `MSTORE8` | 8-byte little-endian loads/stores |
| Stack | `PUSH0`–`PUSH8`, `POP`, `DUPn`, `SWAPn` | push literals are little-endian |
| Flow | `CALLF`, `RETF`, `RJUMP`, `RJUMPI`, `RJUMPV` | conditional jumps 3 gas |
| Exit | `RETURN`, `REVERT`, `INVALID` | unchanged |

Anything else, including state, environment and call opcodes, is not available inside an EVM64 section. Memory is shared, so data can be passed through memory.

## Sample code

Illustrative EOF layout: a regular entry section calling a 64-bit helper:

```text
types:
  section 0: type 0x00 (regular EVM)   inputs=0 outputs=0x80
  section 1: type 0x02 (EVM64)         inputs=2 outputs=1

section 0:                 ; regular EVM
  PUSH1 7
  PUSH1 5
  CALLF 1                  ; enter EVM64 mode
  ...                      ; result back as 256-bit, upper bits zero
  RETURN

section 1:                 ; EVM64: operates on low 64 bits only
  ADD                      ; (a + b) mod 2^64, 2 gas
  RETF
```

## Things to know

- Status is **Draft**, with security considerations and test cases still marked TODO.
- It depends on EOF ([EIP-3540](/eip-3540/), [EIP-4750](/eip-4750/)), which is not scheduled for mainnet, so this proposal cannot ship on its own.
- Trade-off versus [EIP-7937](/eip-7937/): smaller bytecode (no prefix bytes), but only for EOF contracts, and calling into state or environment requires leaving the EVM64 section.
- Note the endianness change: `BYTE`, `PUSHn`, `MLOAD64` and `MSTORE64` are little-endian here, unlike regular EVM.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7961
