EIP-7958 EVM64 little-endian instructions (EVM64 - Little endian opcodes)
No call decision · EVM & execution · EIP status Stagnant · created 2025-05-26
A proposal to add BYTE64, MLOAD64, MSTORE64, and PUSH*64, the instructions in EVM 64-bit mode (EVM64, EIP-7937) whose behavior depends on byte order, in little-endian form.
Why it is needed
The EVM has so far handled values in 256-bit units and used big-endian byte ordering, laying bytes out from the most significant one first. EIP-7937 proposed EVM64, a lighter 64-bit operation mode, but the operations in its core specification produce the same result regardless of which end bytes are read from, so they did not need to define a byte order. However, instructions that read and write values in memory, push constants written in code onto the stack, or extract a single byte from a value only have well-defined behavior once a byte order is fixed. This EIP defines exactly those four kinds of instructions (BYTE64, MLOAD64, MSTORE64, PUSH*64) in little-endian order, laying out bytes from the least significant one first, so they can be deployed together with EIP-7937.
What changes
Today
- The EVM handles values in 256-bit units and reads them big-endian
- The EVM64 core specification (EIP-7937) only defines operations that are independent of byte order
- There are no dedicated instructions for exchanging 64-bit values with memory or loading them as constants
After EIP-7958
- The instructions BYTE64, MLOAD64, MSTORE64, and PUSH2_64 through PUSH8_64 are added
- These instructions read and write 64-bit values in little-endian order
- All gas costs are set to the new constant G_VERYLOW64 (2)
Who is affected
- Client teams: EVM implementations must add four new opcodes and the gas constant G_VERYLOW64.
- Contract and compiler developers: Code using EVM64 gains a way to read and write 64-bit values to memory and load them as constants.
- Ordinary users: There is no directly perceptible change. This is a proposal about internal EVM behavior.
In depth
Division of roles with EIP-7937
The core specification of EVM64 is EIP-7937. The 64-bit operations in the core specification behave the same regardless of byte order, so they are endian-independent. By contrast, the bitwise operation that extracts a specific byte from a value (BYTE64), memory input/output (MLOAD64, MSTORE64), and the operation that pushes a literal written in code onto the stack (PUSH*64) are instructions whose behavior must expose an endianness. This EIP groups just those instructions together, defines them in little-endian order, and states that they can be deployed alongside EIP-7937. It does not spell out detailed design rationale in this document and instead directs readers to the core specification, EIP-7937.
BYTE64 (0xc01a): byte extraction on a little-endian basis
BYTE64 has opcode 0xc01a, and its behavior is defined as (x >> i * 8) & 0xFF. It shifts value x right by i times 8 bits and keeps only the last byte, so when i is 0 it yields the least significant byte. The source text explicitly notes that this definition has shifted from the existing big-endian basis to a little-endian basis. The gas cost is the new constant this EIP defines, G_VERYLOW64, with a value of 2.
MLOAD64 (0xc051) and MSTORE64 (0xc052): 64-bit memory input/output
MLOAD64 (0xc051) reads a 64-bit integer from memory in little-endian order and pushes it onto the stack, and MSTORE64 (0xc052) reads a 64-bit integer from the stack and stores it to memory in little-endian order. Both instructions have a gas cost of G_VERYLOW64 (2), and memory expansion cost is computed on an 8-byte basis. In the source example, reading the 8-byte array [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] with MLOAD64 pushes the 64-bit integer 0x0807060504030201 onto the stack. Since 64-bit mode always operates on only the lowest 64 bits, other 256-bit opcodes that encounter this value on the stack see it as 0x00..00 0807060504030201. Storing the same value with MSTORE64 records the original array again.
PUSH2_64 (0xc061) through PUSH8_64 (0xc067): literal push
PUSH2_64 (0xc061) through PUSH8_64 (0xc067) are instructions that each append a 2-to-8-byte literal immediately following them. The literal is read in little-endian order and pushed onto the stack. In the source example, executing the byte sequence 0xc0 0x67 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 leaves a single value, 0x00..00 0807060504030201, on the stack. The range the source defines runs from PUSH2_64 for 2 bytes through PUSH8_64 for 8 bytes. The gas cost is likewise G_VERYLOW64 (2).
Open parts and document status
The source still has unfilled sections. Test cases and reference implementation are marked as to be added, and security considerations are marked as needing discussion. It states that no backward compatibility issues have been found. The document status is Stagnant, meaning the proposal is classified as halted after a period of no progress. Content may change if discussion resumes.