6

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

3

The 2 arguments to the RETURN opcode are offsets into memory: the starting and ending offset.

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

Example:

If memory is [5, 6, 7, 8, 9, 10], a return with offsets 1, 4 would produce a result (output) of 3 bytes (6, 7, 8).

  • 1
    Memory as in the "storage" mechanism, or as in treating the stack like a flat array of memory? – Earlz Aug 15 '16 at 21:17
  • Memory as what is stored by the MSTORE opcode. – eth Aug 15 '16 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 '16 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 '16 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... – silasdavis Oct 4 '16 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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