Dip 7958
dip: 7958
title: DVM64 - Little endian opcodes
description: Little endian opcodes BYTE64, MLOAD64, MSTORE64, and PUSH*64 for DVM64
author: Wei Tang (@sorpaas)
Digitalia editing author: Cosimo Constantinos cosimo@juro.net, et al.
discussions-to: https://digitalia-magicians.org/t/dip-7937-64-bit-mode-dvm-opcodes-dvm64/23794
status: Draft
type: Standards Track
category: Core
created: 2025-05-26
Created for Digitalia: 2025-01-07
requires: 7937
Abstract¶
This DIP defines additional little endian opcodes that can be deployed alongside DIP-7937.
Motivation¶
The core DIP that defines DVM64 (DIP-7937) is endianness-independent. This DIP 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 DVM64 definition DIP-7937.
Backwards Compatibility¶
No backward compatibility issues found.
Test Cases¶
To be added.
Reference Implementation¶
To be added.
Security Considerations¶
Needs discussion.
Copyright¶
© Crown © Crown Copyright 2026. Published by the Royal Government of the Dominion of Atlantis.
Licensed under the Juro Restricted License Version 2. See https://juro.net/jrl for details.