The RETURN opcode in the EVM takes 2 arguments(ie, consumes two elements from the stack), but what do they represent? I tried to understand the yellow paper describing them, but I don't understand the notation used.

For reference this is the section in the yellow paper: enter image description here

1 Answer 1


The 2 arguments to the RETURN opcode are a starting offset and length specifying a segment of memory.

The EVM execution is stopped and data consisting of the memory bytes from [start, start+len-1] are the output of the execution.


If memory is [5, 6, 7, 8, 9, 10], a return with starting offset=1 and length=4 would produce a result (output) of 4 bytes (6, 7, 8, 9).

  • 1
    Memory as in the "storage" mechanism, or as in treating the stack like a flat array of memory?
    – Earlz
    Aug 15, 2016 at 21:17
  • Memory as what is stored by the MSTORE opcode.
    – eth
    Aug 15, 2016 at 23:27
  • By chance do you know of a "plain text" reference for all the opcode arguments? Other than the yellow paper's mathy notation, I can't find any actual reference beyond the code itself (which isn't always too clear)
    – Earlz
    Aug 16, 2016 at 17:52
  • Regarding EVM code, since there's implementations across a number of languages that may help reason about them. I don't know of a simpler reference and IMHO a new, clearer reference is more than welcome but it should still be complete.
    – eth
    Aug 17, 2016 at 11:00
  • You may find our implementation is fairly readable reference for opcodes (though I would like increase the number of comments there): github.com/eris-ltd/eris-db/blob/develop/manager/eris-mint/evm/…. @Ethan has a nice low-level guide, though not completely comprehensive as a spec github.com/ebuchman/evm-tools/blob/master/analysis/guide.md. I too would like to see the Ethereum spec presented in a more appropriate format than the yellow paper... Oct 4, 2016 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.