
Solidity Programming Essentials
By :

Assembly blocks can return values to their parent scope. Since variables get deallocated after the block execution, returning values from an assembly block can become quite important. There are a couple of ways to return values from the assembly block.
One way to return values from a function that, in turn, gets a value from assembly code is to use a variable name in the function signature. The same variable should be assigned a value from the assembly code. The next function shown declares a return
type using retval
as its name. In assembly code, the retval
variable is assigned a constant value, and this gets automatically returned as part of the function's return
value. Note that the return
keyword or opcode is not used in this case:
function usingReturnVariable() public pure returns (uint256 retval) { assembly { ...