This EIP defines additional little endian opcodes that can be deployed alongside EIP-7937.
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
.
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
: 2BYTE64
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
.
For detailed rationale discussion, please see the core EVM64 definition EIP-7937.
No backward compatibility issues found.
To be added.
To be added.
Needs discussion.
Copyright and related rights waived via CC0.