Last active
February 12, 2019 22:23
-
-
Save gdebenito/8967c68fa088bfa090538b149afc9461 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.4.22 <0.6.0; | |
contract AssemblyArray { | |
function bar(uint[] calldata x, uint256 y) external pure | |
returns (uint256 offset, uint256 length, uint256 x0, uint256 x1, uint256 y0) { | |
assembly { | |
calldatacopy(0x0,4,36) | |
// x offset | |
calldatacopy(0x20,68,100) // x length | |
calldatacopy(0x40,100,132) // x[0] | |
calldatacopy(0x60,132,164) // x[1] | |
calldatacopy(0x80,36,68) // y value | |
return(0x0,160) | |
// return the 5 arguments * 32 bytes each one | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment