---
eip: 7979
label: EIP-7979
title: Call and Return Opcodes for the EVM
status: Review
type: Standards Track
category: Core
created: 2025-12-17
official: https://eips.ethereum.org/EIPS/eip-7979
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7979.md
canonical: https://eips.huatuo.xyz/eip-7979/
lang: en
tldr: Adds three EVM opcodes, `CALLSUB`, `CALLDEST` and `RETURNSUB`, plus a hidden return stack, so compilers can express function calls directly instead of faking them with dynamic jumps, making code smaller, cheaper and statically analysable.
tags: [evm, opcodes, subroutines, control-flow, compilers]
---

# EIP-7979: Call and Return Opcodes for the EVM

> Three new instructions to support calls and returns.

**TL;DR:** Adds three EVM opcodes, `CALLSUB`, `CALLDEST` and `RETURNSUB`, plus a hidden return stack, so compilers can express function calls directly instead of faking them with dynamic jumps, making code smaller, cheaper and statically analysable.

## What problem does it solve?

The EVM has no instruction for "call a function" or "return from it". Compilers like Solidity fake both with `JUMP`: they push a return address onto the data stack, jump into the function, and at the end jump back to whatever address is on the stack. That has two costs:

- **Gas and bytes.** Every call and return needs extra pushes, swaps and jumpdests.
- **Opaque control flow.** A return is a jump whose destination is *data*. Any tool that wants to follow the program's control flow (validators, AOT/JIT compilers, formal verifiers) must consider every possible destination, which can take quadratic time or worse. For on-chain analysis at deploy or run time, anything worse than linear is a denial-of-service risk. [EIP-8173](/eip-8173/) lays out this problem in detail.

## How it works

The EVM gains a **return stack** (up to 1024 entries) that EVM code cannot read or modify, and three instructions:

| Opcode | Name | Gas | Effect |
| --- | --- | --- | --- |
| `0xBC` | `CALLSUB` | 8 | Pop a destination from the data stack, push `PC + 1` onto the return stack, jump. The destination must be a `CALLDEST`. |
| `0xBB` | `CALLDEST` | 1 | Marks a subroutine entry; otherwise a no-op like `JUMPDEST`. |
| `0xBF` | `RETURNSUB` | 5 | Pop the return stack into `PC`. |

Calling a non-`CALLDEST`, overflowing the return stack, or returning with an empty return stack is an exceptional halt. A `CALLDEST` is also a valid `JUMP`/`JUMPI` target, which allows tail calls: jumping into a subroutine reuses the caller's return address, so recursion in tail position runs at constant return-stack depth.

Because return addresses live outside the data stack, code cannot corrupt them. Code that avoids dynamic jumps can be checked in a single linear pass, which the authors argue enables safe AOT/JIT compilation and cheaper ZK proving of EVM code. There are no code sections or immediates, so unlike EOF ([EIP-3540](/eip-3540/)) existing code is unaffected.

## Sample code

The spec's simplest test, as bytecode `0x6004BC00BBBF`:

```
PC 0: PUSH1 0x04   ; destination of the subroutine
PC 2: CALLSUB      ; return stack = [3], jump to 4
PC 3: STOP
PC 4: CALLDEST     ; subroutine entry
PC 5: RETURNSUB    ; pop 3 -> PC = 3
; total gas: 3 + 8 + 1 + 5 + 0 = 17
```

A squaring routine, from the spec's comparison:

```
SQUARE:      calldest          ; 1
             dup1              ; 3
             mul               ; 5
             returnsub         ; 5
CALL_SQUARE: calldest
             push 2
             push SQUARE
             callsub           ; 8
             returnsub
```

The authors' example shrinks from 17 to 12 bytes and from 50 to 34 gas versus the `JUMP`-based version.

## Things to know

- **Status: Review.** Not scheduled for a network upgrade; gas costs still need benchmarking according to the spec.
- Fully backwards compatible: opcodes `0xBB`, `0xBC`, `0xBF` were unassigned, and existing code behaves exactly as before. `0xBD`/`0xBE` are left free for a possible future multi-way jump.
- Savings only appear once compilers emit the new opcodes; existing contracts gain nothing.
- Explicit subroutines have a long history: earlier attempts include [EIP-615](/eip-615/) and [EIP-2315](/eip-2315/). The spec's performance figures also use the 64-bit opcodes of [EIP-7937](/eip-7937/).


---

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