Solidity REPL
Debugging & errors

Memory-safe assembly

Annotate an inline assembly block and perform arithmetic in Yul.

Solidity 0.8.36REPL modeDebug capture

Why use this example

Use this pattern to reproduce a failure or follow an execution from Solidity source into calls and EVM opcodes. The entry isolates memory-safe assembly so its input, result, and state changes stay easy to compare.

Solidity to run

function addInAssembly(uint256 left, uint256 right) public pure returns (uint256 result) {
  assembly ("memory-safe") { result := add(left, right) }
}

addInAssembly(20, 22)

Official Solidity reference

Compare this focused investigation with the complete language definition in the Solidity documentation.

Advanced safe use of memory

What to expect

The annotated Yul block adds 20 and 22 to return 42 while making its opcode steps available for inspection.

Continue the investigation

Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.

Read about debugging Execution diagnosis