---
eip: 4573
label: EIP-4573
title: Procedures for the EVM
status: Stagnant
type: Standards Track
category: Core
created: 2021-12-16
requires: 2315, 3540, 3670, 3779, 4200
official: https://eips.ethereum.org/EIPS/eip-4573
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4573.md
canonical: https://eips.huatuo.xyz/eip-4573/
lang: en
tldr: Proposed adding real procedures to the EVM, with declared inputs and outputs and automatically managed call frames in memory, so compilers get a structured, statically checkable calling convention.
tags: [evm, opcodes, eof, procedures, core]
---

# EIP-4573: Procedures for the EVM

> Introduces support for EVM Procedures.

**TL;DR:** Proposed adding real procedures to the EVM, with declared inputs and outputs and automatically managed call frames in memory, so compilers get a structured, statically checkable calling convention.

## What problem does it solve?

EVM bytecode has no structure: a "function" is just a region you `JUMP` into and out of, with no declared interface. Compilers have to invent their own calling conventions with dynamic jumps, and tools cannot easily check that code respects them. There is also no built-in way to allocate local variables per call; compilers juggle the 1024-item data stack or hand-manage memory.

EIP-4573 proposes *procedures*: delimited blocks of code that can only be entered through a defined interface and that get their own frame of local memory, in the style of x86 `ENTER`/`LEAVE`.

## How it works

It builds on the subroutines of [EIP-2315](/eip-2315/) (`JUMPSUB`/`RETURNSUB`), EOF code sections ([EIP-3540](/eip-3540/)) and the validation rules of [EIP-3779](/eip-3779/). Five instructions are added (opcode numbers were left unassigned):

| Instruction | Role |
| --- | --- |
| `ENTERPROC` | Marks a procedure's entry; declares `n_inputs`, `n_outputs`, `n_locals` |
| `LEAVEPROC` | Marks the procedure's end; frees its frame and returns |
| `CALLPROC` | Calls procedure N in code section M (the only legal way in) |
| `RETURNPROC` | Early return from the procedure |
| `FRAMEADDRESS` | Pushes `FP + offset`, the address of a local in the current frame |

Locals live on a **frame stack in memory** that starts at address 0 and grows downwards into negative (signed) addresses. The frame pointer `FP` moves down on each call and back up on return. Because frames are ordinary memory, locals can be read and written with `MLOAD`/`MSTORE`, which suits languages that take pointers to stack variables. Memory-expansion cost is adjusted to count words used both above and below 0.

Safety comes from validation at deploy time: no nested procedures, no jumping into a procedure body from outside, and the declared input/output counts must be present on the stack.

## Sample code

Storing and loading a local variable in the current frame, from the spec:

```
PUSH 0xdada
FRAMEADDRESS 32
MSTORE          ; local at FP+32 = 0xdada

FRAMEADDRESS 32
MLOAD           ; push it back
```

## Things to know

- Status: **Stagnant**. Opcodes were never assigned and it did not ship.
- The author describes it as [EIP-615](/eip-615/) "refined and refactored into bite-sized pieces".
- EVM Object Format work later took a different route to functions: code sections with `CALLF`/`RETF` in [EIP-4750](/eip-4750/), with static relative jumps from [EIP-4200](/eip-4200/).
- The signed, downward-growing memory model would have been a notable change to how memory size and cost are tracked.


---

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