Skip to content

Instantly share code, notes, and snippets.

@gdebenito
Last active February 12, 2019 22:23
Show Gist options
  • Save gdebenito/8967c68fa088bfa090538b149afc9461 to your computer and use it in GitHub Desktop.
Save gdebenito/8967c68fa088bfa090538b149afc9461 to your computer and use it in GitHub Desktop.
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