---
eip: 4200
label: EIP-4200
title: EOF - Static relative jumps
status: Stagnant
type: Standards Track
category: Core
created: 2021-07-16
requires: 3540, 3670
official: https://eips.ethereum.org/EIPS/eip-4200
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4200.md
canonical: https://eips.huatuo.xyz/eip-4200/
lang: en
tldr: "Adds RJUMP, RJUMPI and RJUMPV to EOF-formatted EVM code: jumps whose targets are fixed relative offsets in the bytecode, so they are validated at deploy time, need no JUMPDEST and cost less gas."
tags: [evm, eof, opcodes, core]
---

# EIP-4200: EOF - Static relative jumps

> RJUMP, RJUMPI and RJUMPV instructions with a signed immediate encoding the jump destination

**TL;DR:** Adds RJUMP, RJUMPI and RJUMPV to EOF-formatted EVM code: jumps whose targets are fixed relative offsets in the bytecode, so they are validated at deploy time, need no JUMPDEST and cost less gas.

## What problem does it solve?

The EVM has only dynamic jumps: `JUMP` and `JUMPI` take their destination from the stack. That is flexible, but it means the target can only be checked at run time, every destination needs a `JUMPDEST` marker, and static analysis of bytecode (for tools, JITs or validators) is hard because any jump could in principle go anywhere.

Yet most control flow a compiler emits (if/else, loops, many function calls) has a target known at compile time. EIP-4200 gives compilers static jumps for those cases, as part of the EVM Object Format (EOF) container introduced by [EIP-3540](/eip-3540/).

## How it works

Three opcodes, available only in valid EOF code (in legacy bytecode they cause an exceptional halt, so existing contracts are unaffected):

| Opcode | Immediate | Behavior |
| --- | --- | --- |
| `RJUMP` (0xe0) | 16-bit signed offset | Jump to `PC_post_instruction + offset` |
| `RJUMPI` (0xe1) | 16-bit signed offset | Pop `condition`; jump if non-zero, else fall through |
| `RJUMPV` (0xe2) | `max_index` (u8) + `max_index+1` offsets | Pop `case`; jump via table, fall through if `case > max_index` |

- Offsets are two's-complement big-endian and relative to the byte *after* the whole instruction, so code is relocatable.
- Deploy-time validation (extending [EIP-3670](/eip-3670/)) checks that every target is the start of an instruction: not inside `PUSH` data or another jump's immediate, and not outside the code section.
- Because targets are pre-validated, gas is lower: `RJUMP` costs 2, `RJUMPI` and `RJUMPV` cost 4. Targets do not need a `JUMPDEST`, saving deployment bytes and the 1 gas it costs to pass through one.
- A 16-bit signed offset covers jumps of up to 32767 bytes, which the authors consider enough given the code size limits of [EIP-170](/eip-170/) and [EIP-3860](/eip-3860/).
- Dynamic `JUMP` is not removed by this EIP; it was expected to remain for things like returning to a caller.

## Sample code

A loop that counts down from 3, in EOF assembly with byte offsets shown:

```text
00: PUSH1 0x03        ; counter
02: DUP1              ; loop:  [c, c]
03: ISZERO            ;        [c==0, c]
04: RJUMPI +7         ; if c==0 -> 0x0e (0x07 + 7)
07: PUSH1 0x01
09: SWAP1
0a: SUB               ; c = c - 1
0b: RJUMP -12         ; back to loop at 0x02 (0x0e - 12)
0e: STOP
```

Encoding of the instructions themselves:

```text
RJUMP  -12        -> e0 ff f4
RJUMPI +7         -> e1 00 07
RJUMPV 1, +3, +9  -> e2 01 00 03 00 09   ; 2-entry table
```

Note: offsets are computed from the address just after the full instruction (`PC_post_instruction`); compilers and assemblers do this arithmetic for you.

## Things to know

- Status is **Stagnant**. It depends on EOF ([EIP-3540](/eip-3540/), [EIP-3670](/eip-3670/)), which is also Stagnant; the full EOF package is tracked in [EIP-7692](/eip-7692/).
- `RJUMPV 0 offset` behaves as an inverted `RJUMPI` (jump when the value is zero).
- If `RJUMPV`'s `case` is out of range, execution simply continues with the next instruction, so the default branch usually follows it.
- Relative addressing made the `PC` opcode unnecessary in EOF code, according to the rationale.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-4200
