EIP-7958: EVM64 - Little endian opcodes

Little endian opcodes `BYTE64`, `MLOAD64`, `MSTORE64`, and `PUSH*64` for EVM64


Metadata
Status: DraftStandards Track: CoreCreated: 2025-05-26
Authors
Wei Tang (@sorpaas)
Requires

Abstract


This EIP defines additional little endian opcodes that can be deployed alongside EIP-7937.

Motivation


The core EIP that defines EVM64 (EIP-7937) is endianness-independent. This EIP defines those additional opcodes that must expose endianness. They are the bitwise opcode BYTE64, memory opcodes MLOAD64 and MSTORE64, and stack opcodes PUSH*64.

Specification


The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174.

We define the following gas cost constant:

  • G_VERYLOW64: 2

BYTE64

BYTE64 (0xc01a) is defined as (x >> i * 8) & 0xFF. Note that the definition is changed from big endian to little endian.

The gas cost is G_VERYLOW64.

MLOAD64 and MSTORE64

MLOAD64 (0xc051) will load a 64-bit integer in little endian onto the stack. MSTORE64 (0xc052) will read an 64-bit integer from the stack, and store it to memory in little endian.

The gas cost for both opcodes is G_VERYLOW64. The memory resizing costs count as 8 bytes.

As an example, [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] is an array of 8 bytes (64 bits). Calling MLOAD64 to load this 8-byte value to stack will read it in little endian, resulting in 64-bit integer 0x0807060504030201. 64-bit mode always operate on only the least significant 64 bits. When another 256-bit opcodes encounter this value on stack, it will be 0x00..00 0807060504030201. Calling MSTORE64 to store this value to memory will result in the array [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08].

PUSH*64

PUSH2_64 (0xc061) to PUSH8_64 (0xc067) follows 2-byte to 8-byte literal. The literal is read little endian and pushed onto the stack.

The gas cost for them is G_VERYLOW64.

As an example, 0xc0 0x67 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 will result in a stack with single value 0x00..00 0807060504030201.

Rationale


For detailed rationale discussion, please see the core EVM64 definition EIP-7937.

Backwards Compatibility


No backward compatibility issues found.

Test Cases


To be added.

Reference Implementation


To be added.

Security Considerations


Needs discussion.

Copyright


Copyright and related rights waived via CC0.