{"eip":4520,"title":"Multi-byte opcodes prefixed by EB and EC.","description":"Reserve `0xEB` and `0xEC` for usage as extended opcode space.","authors":["Brayton Goodall (@Spore-Druid-Bray)","Mihir Faujdar (@uink45)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2021-12-01","discussionsTo":"https://ethereum-magicians.org/t/multi-byte-opcodes/7681","repo":"EIPs","label":"EIP-4520","officialUrl":"https://eips.ethereum.org/EIPS/eip-4520","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4520.md","url":"https://eips.huatuo.xyz/eip-4520/","tldr":{"en":"Proposed reserving the unused opcodes 0xEB and 0xEC as prefixes for two- and three-byte opcodes, so the EVM could grow beyond 256 instructions.","ja":"未使用のオペコード 0xEB と 0xEC を 2 バイト・3 バイトオペコードのプレフィックスとして予約し、EVM が 256 命令を超えて拡張できるようにする提案。","ko":"사용되지 않는 opcode 0xEB와 0xEC를 2바이트·3바이트 opcode의 접두사로 예약해 EVM이 256개를 넘는 명령어로 확장될 수 있게 하자는 제안.","zh":"提议将未使用的操作码 0xEB 和 0xEC 保留为两字节和三字节操作码的前缀，使 EVM 可以超出 256 条指令。"},"tags":["evm","opcodes","core","eof"],"explainers":{"en":{"lang":"en","tldr":"Proposed reserving the unused opcodes 0xEB and 0xEC as prefixes for two- and three-byte opcodes, so the EVM could grow beyond 256 instructions.","tags":["evm","opcodes","core","eof"],"related":[3540,663],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-4520/","markdown":"## What problem does it solve?\n\nEvery EVM instruction is a single byte, so there can be at most 256 opcodes. Many slots are already used, and new features (new arithmetic, new call variants, experimental instructions) keep competing for the remaining ones. Rarely used instructions don't really need to be one byte; spending a short opcode on them is wasteful.\n\nEIP-4520 proposes an \"escape hatch\": keep single-byte opcodes for common operations and open a much larger space of multi-byte opcodes for everything else.\n\n## How it works\n\n- `0xEB` and `0xEC` are reserved as **prefix bytes**. A prefix plus one following byte forms a two-byte opcode, giving up to 2 × 255 = 510 new instructions.\n- The second byte can mirror an existing opcode for related functionality. The spec's examples: a new arithmetic op at `0xEC 01` (next to `ADD`) and a new call variant at `0xEB F4` (next to `DELEGATECALL`).\n- Doubling the prefix (`0xEB EB`, `0xEC EC`, `0xEB EC`, `0xEC EB`) opens a **three-byte** space. The idea is to place experimental opcodes there first and promote them to shorter encodings later if they prove useful and safe.\n- The prefix bytes themselves do not touch the stack or memory. An undefined multi-byte opcode behaves like any undefined opcode: `INVALID`, not `NOP`.\n\nBoth bytes were chosen from the unassigned `0xE*` range, which also contains `0xEF`, the byte reserved for the EVM Object Format ([EIP-3540](/eip-3540/)).\n\n## Sample code\n\nHow a disassembler might decode the proposed scheme (pseudocode):\n\n```python\nPREFIXES = {0xEB, 0xEC}\n\ndef next_opcode(code: bytes, pc: int) -\u003e tuple[bytes, int]:\n    \"\"\"Return (opcode bytes, length) at pc under EIP-4520.\"\"\"\n    if code[pc] not in PREFIXES:\n        return code[pc:pc + 1], 1                  # ordinary 1-byte opcode\n    if pc + 1 \u003c len(code) and code[pc + 1] in PREFIXES:\n        return code[pc:pc + 3], 3                  # e.g. EB EB xx (3-byte)\n    return code[pc:pc + 2], 2                      # e.g. EC 01 (2-byte)\n\n# Any multi-byte opcode not yet defined executes as INVALID.\n```\n\n## Things to know\n\n- Status: **Stagnant**. It was never scheduled for a network upgrade, and `0xEB`/`0xEC` are not reserved as prefixes on mainnet.\n- Backwards-compatibility caveat from the spec: if `0xEB`/`0xEC` were ever assigned meanings in deployed code, reinterpreting them could break that code.\n- Later work on extending the instruction set has mostly gone through EOF, which adds immediates and code validation instead of prefix bytes (e.g. [EIP-663](/eip-663/) `DUPN`/`SWAPN`).\n- With legacy (non-EOF) bytecode, multi-byte opcodes also complicate jump-destination analysis, because a byte might be the second half of an instruction.\n"},"ja":{"lang":"ja","tldr":"未使用のオペコード 0xEB と 0xEC を 2 バイト・3 バイトオペコードのプレフィックスとして予約し、EVM が 256 命令を超えて拡張できるようにする提案。","tags":["evm","opcodes","core","eof"],"related":[3540,663],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-4520/","markdown":"## 何を解決するのか\n\nEVM の命令はすべて 1 バイトなので、オペコードは最大でも 256 個です。すでに多くの枠が使われており、新機能（新しい算術命令、新しい呼び出しの種類、実験的な命令）が残りの枠を奪い合っています。あまり使われない命令は 1 バイトである必要はなく、短いオペコードを割り当てるのは無駄です。\n\nEIP-4520 は「逃げ道」を提案します。よく使う操作には 1 バイトのオペコードを残し、それ以外のためにはるかに大きな複数バイトのオペコード空間を開くというものです。\n\n## 仕組み\n\n- `0xEB` と `0xEC` を**プレフィックスバイト**として予約します。プレフィックスと後続の 1 バイトで 2 バイトのオペコードになり、最大 2 × 255 = 510 個の新しい命令を定義できます。\n- 2 バイト目は、関連する機能を持つ既存のオペコードに対応させることができます。仕様の例は、新しい算術命令を `0xEC 01`（`ADD` の隣）に、新しい呼び出しの種類を `0xEB F4`（`DELEGATECALL` の隣）に置くというものです。\n- プレフィックスを重ねる（`0xEB EB`、`0xEC EC`、`0xEB EC`、`0xEC EB`）と、**3 バイト**の空間が開きます。実験的なオペコードをまずそこに置き、有用で安全だと分かれば後でより短いエンコーディングに昇格させる、という考え方です。\n- プレフィックスバイト自体はスタックにもメモリにも触れません。未定義の複数バイトオペコードは、他の未定義オペコードと同様に `NOP` ではなく `INVALID` として動作します。\n\n2 つのバイトはどちらも未割り当ての `0xE*` の範囲から選ばれました。この範囲には EVM Object Format 用に予約された `0xEF` も含まれます（[EIP-3540](/eip-3540/)）。\n\n## サンプルコード\n\n逆アセンブラが提案された方式をデコードする方法の例（擬似コード）:\n\n```python\nPREFIXES = {0xEB, 0xEC}\n\ndef next_opcode(code: bytes, pc: int) -\u003e tuple[bytes, int]:\n    \"\"\"Return (opcode bytes, length) at pc under EIP-4520.\"\"\"\n    if code[pc] not in PREFIXES:\n        return code[pc:pc + 1], 1                  # ordinary 1-byte opcode\n    if pc + 1 \u003c len(code) and code[pc + 1] in PREFIXES:\n        return code[pc:pc + 3], 3                  # e.g. EB EB xx (3-byte)\n    return code[pc:pc + 2], 2                      # e.g. EC 01 (2-byte)\n\n# Any multi-byte opcode not yet defined executes as INVALID.\n```\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。ネットワークアップグレードに予定されたことはなく、メインネットでは `0xEB`/`0xEC` はプレフィックスとして予約されていません。\n- 仕様にある後方互換性の注意点: デプロイ済みのコードで `0xEB`/`0xEC` に意味が割り当てられていた場合、解釈を変えるとそのコードが壊れる可能性があります。\n- 命令セット拡張に関するその後の取り組みは、プレフィックスバイトの代わりにイミディエイトとコード検証を追加する EOF を通じて進められてきました（例: [EIP-663](/eip-663/) の `DUPN`/`SWAPN`）。\n- レガシー（非 EOF）バイトコードでは、あるバイトが命令の後半部分である可能性があるため、複数バイトオペコードはジャンプ先の解析も複雑にします。\n"},"ko":{"lang":"ko","tldr":"사용되지 않는 opcode 0xEB와 0xEC를 2바이트·3바이트 opcode의 접두사로 예약해 EVM이 256개를 넘는 명령어로 확장될 수 있게 하자는 제안.","tags":["evm","opcodes","core","eof"],"related":[3540,663],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-4520/","markdown":"## 어떤 문제를 해결하나요?\n\nEVM 명령어는 모두 1바이트라서 opcode는 최대 256개입니다. 이미 많은 자리가 쓰였고, 새로운 기능(새 산술 연산, 새 호출 변형, 실험적 명령어)이 남은 자리를 두고 계속 경쟁합니다. 거의 쓰이지 않는 명령어에는 1바이트가 필요하지 않으며, 짧은 opcode를 쓰는 것은 낭비입니다.\n\nEIP-4520은 \"탈출구\"를 제안합니다. 흔한 연산에는 1바이트 opcode를 유지하고, 나머지에는 훨씬 큰 멀티바이트 opcode 공간을 여는 것입니다.\n\n## 어떻게 동작하나요?\n\n- `0xEB`와 `0xEC`를 **접두사 바이트**로 예약합니다. 접두사와 뒤따르는 1바이트가 2바이트 opcode를 이루며, 최대 2 × 255 = 510개의 새 명령어를 만들 수 있습니다.\n- 두 번째 바이트는 관련 기능을 하는 기존 opcode에 대응시킬 수 있습니다. 스펙의 예시는 새 산술 연산을 `0xEC 01`(`ADD` 옆)에, 새 호출 변형을 `0xEB F4`(`DELEGATECALL` 옆)에 두는 것입니다.\n- 접두사를 두 번 쓰면(`0xEB EB`, `0xEC EC`, `0xEB EC`, `0xEC EB`) **3바이트** 공간이 열립니다. 실험적 opcode를 먼저 여기에 두고, 유용하고 안전하다고 입증되면 나중에 더 짧은 인코딩으로 승격시킨다는 구상입니다.\n- 접두사 바이트 자체는 스택이나 메모리를 건드리지 않습니다. 정의되지 않은 멀티바이트 opcode는 다른 정의되지 않은 opcode와 마찬가지로 `NOP`이 아니라 `INVALID`로 동작합니다.\n\n두 바이트는 모두 할당되지 않은 `0xE*` 범위에서 골랐으며, 이 범위에는 EVM Object Format용으로 예약된 `0xEF`도 있습니다([EIP-3540](/eip-3540/)).\n\n## 샘플 코드\n\n디스어셈블러가 제안된 방식을 디코딩하는 방법(의사 코드):\n\n```python\nPREFIXES = {0xEB, 0xEC}\n\ndef next_opcode(code: bytes, pc: int) -\u003e tuple[bytes, int]:\n    \"\"\"Return (opcode bytes, length) at pc under EIP-4520.\"\"\"\n    if code[pc] not in PREFIXES:\n        return code[pc:pc + 1], 1                  # ordinary 1-byte opcode\n    if pc + 1 \u003c len(code) and code[pc + 1] in PREFIXES:\n        return code[pc:pc + 3], 3                  # e.g. EB EB xx (3-byte)\n    return code[pc:pc + 2], 2                      # e.g. EC 01 (2-byte)\n\n# Any multi-byte opcode not yet defined executes as INVALID.\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 네트워크 업그레이드에 예정된 적이 없으며, 메인넷에서 `0xEB`/`0xEC`는 접두사로 예약되어 있지 않습니다.\n- 스펙의 하위 호환성 주의사항: 배포된 코드에서 `0xEB`/`0xEC`에 의미가 할당된 적이 있다면, 이를 재해석할 때 해당 코드가 깨질 수 있습니다.\n- 명령어 집합 확장에 관한 이후 작업은 대부분 접두사 바이트 대신 immediate와 코드 검증을 추가하는 EOF를 통해 이루어졌습니다(예: [EIP-663](/eip-663/)의 `DUPN`/`SWAPN`).\n- 레거시(비 EOF) 바이트코드에서는 어떤 바이트가 명령어의 두 번째 절반일 수 있기 때문에, 멀티바이트 opcode가 점프 목적지 분석도 복잡하게 만듭니다.\n"},"zh":{"lang":"zh","tldr":"提议将未使用的操作码 0xEB 和 0xEC 保留为两字节和三字节操作码的前缀，使 EVM 可以超出 256 条指令。","tags":["evm","opcodes","core","eof"],"related":[3540,663],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-4520/","markdown":"## 它解决什么问题？\n\nEVM 的每条指令都是单个字节，因此操作码最多只有 256 个。许多位置已被占用，新功能（新的算术运算、新的调用变体、实验性指令）不断争抢剩下的位置。很少使用的指令其实不需要占一个字节，为它们消耗一个短操作码是一种浪费。\n\nEIP-4520 提出了一个\"逃生口\"：常用操作保留单字节操作码，其余操作则开辟一个大得多的多字节操作码空间。\n\n## 它如何运作\n\n- `0xEB` 和 `0xEC` 被保留为**前缀字节**。一个前缀加上后面一个字节构成两字节操作码，最多可提供 2 × 255 = 510 条新指令。\n- 第二个字节可以对应功能相关的现有操作码。规范中的例子：新的算术运算放在 `0xEC 01`（紧邻 `ADD`），新的调用变体放在 `0xEB F4`（紧邻 `DELEGATECALL`）。\n- 重复前缀（`0xEB EB`、`0xEC EC`、`0xEB EC`、`0xEC EB`）会开辟**三字节**空间。其思路是先把实验性操作码放在那里，如果证明有用且安全，再提升到更短的编码。\n- 前缀字节本身不会触及栈或内存。未定义的多字节操作码与任何未定义操作码一样：执行 `INVALID`，而不是 `NOP`。\n\n这两个字节都选自未分配的 `0xE*` 范围，该范围还包含为 EVM 对象格式保留的 `0xEF`（[EIP-3540](/eip-3540/)）。\n\n## 示例代码\n\n反汇编器解码该方案的方式（伪代码）：\n\n```python\nPREFIXES = {0xEB, 0xEC}\n\ndef next_opcode(code: bytes, pc: int) -\u003e tuple[bytes, int]:\n    \"\"\"Return (opcode bytes, length) at pc under EIP-4520.\"\"\"\n    if code[pc] not in PREFIXES:\n        return code[pc:pc + 1], 1                  # ordinary 1-byte opcode\n    if pc + 1 \u003c len(code) and code[pc + 1] in PREFIXES:\n        return code[pc:pc + 3], 3                  # e.g. EB EB xx (3-byte)\n    return code[pc:pc + 2], 2                      # e.g. EC 01 (2-byte)\n\n# Any multi-byte opcode not yet defined executes as INVALID.\n```\n\n## 需要注意\n\n- 状态：**Stagnant**。它从未被排入任何网络升级，主网上 `0xEB`/`0xEC` 也没有被保留为前缀。\n- 规范中的向后兼容性提醒：如果 `0xEB`/`0xEC` 曾在已部署的代码中被赋予含义，重新解释它们可能会破坏这些代码。\n- 后续扩展指令集的工作主要通过 EOF 进行，它增加了立即数和代码验证，而不是前缀字节（例如 [EIP-663](/eip-663/) 的 `DUPN`/`SWAPN`）。\n- 对于传统（非 EOF）字节码，多字节操作码还会使跳转目标分析变得复杂，因为某个字节可能是一条指令的后半部分。\n"}}}
