# `EEVM.Interpreter.Memory`
[🔗](https://github.com/mw2000/eevm/blob/main/lib/eevm/interpreter/memory.ex#L1)

EVM memory — a byte-addressable, dynamically expanding linear memory.

Memory expands in 32-byte chunks. Reads or writes beyond the current size
auto-expand and are zero-filled. Gas cost increases quadratically with
memory size (see `EEVM.Gas.Memory`).

# `t`

```elixir
@type t() :: %EEVM.Interpreter.Memory{
  data: %{required(non_neg_integer()) =&gt; byte()},
  size: non_neg_integer()
}
```

# `copy`

```elixir
@spec copy(t(), non_neg_integer(), non_neg_integer(), non_neg_integer()) :: t()
```

Copies `length` bytes from `src` to `dst` within memory (memmove semantics).

This is the MCOPY operation (EIP-5656). Handles overlapping regions correctly
by reading all source bytes before writing — similar to C's `memmove`.

# `load`

```elixir
@spec load(t(), non_neg_integer()) :: {non_neg_integer(), t()}
```

Loads a 256-bit (32-byte) word from the given byte offset.

This is the MLOAD operation. Unwritten bytes read as zero.

# `new`

```elixir
@spec new() :: t()
```

Creates a new empty memory.

# `read_bytes`

```elixir
@spec read_bytes(t(), non_neg_integer(), non_neg_integer()) :: {binary(), t()}
```

Reads a range of bytes from memory as a binary.

Used by RETURN, REVERT, and LOG operations.

# `size`

```elixir
@spec size(t()) :: non_neg_integer()
```

Returns the current memory size in bytes (always a multiple of 32).

# `store`

```elixir
@spec store(t(), non_neg_integer(), non_neg_integer()) :: t()
```

Stores a 256-bit (32-byte) word at the given byte offset.

This is the MSTORE operation. The value is stored big-endian,
which is the EVM's byte ordering convention.

# `store_byte`

```elixir
@spec store_byte(t(), non_neg_integer(), non_neg_integer()) :: t()
```

Stores a single byte at the given offset.

This is the MSTORE8 operation.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
