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.
Asked
Active
Viewed 1,441 times
10
Earlz
- 471
- 4
- 16
1 Answers
5
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.
Example:
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).
eth
- 85,679
- 53
- 285
- 406

MSTOREopcode. – eth Aug 15 '16 at 23:27RETURNare not start and end of the return data, but start and length. – gernot Sep 06 '22 at 17:20