Skip to content

Instantly share code, notes, and snippets.

@frangio
Created August 28, 2025 18:52
Show Gist options
  • Save frangio/399b4a0d23728d55ec867e9707eae759 to your computer and use it in GitHub Desktop.
Save frangio/399b4a0d23728d55ec867e9707eae759 to your computer and use it in GitHub Desktop.

Parameters

  • DUPN_OPCODE = 0xE6
  • SWAPN_OPCODE = 0xE7

Instructions

Upon activation of this EIP, introduce two new instructions SWAPN and DUPN, both with an immediate operand n ∈ [17, 235].

  • SWAPN n:
  • DUPN n:

Encoding

Each instruction spans 2 bytes. The first byte is either SWAPN_OPCODE or DUPN_OPCODE. The second byte is f(n) as defined by the following Python code:

def f(n: int) -> int:
    assert 17 <= n <= 235
    y = n - 17
    if y < 0x5B:
        return y
    else:
        return y - 0x5B + 0x80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment