I've a couple of questions.
mload function returns the data that resides on the address we pass to mload. Is this correct ?
add function is used to give us the address from 0 to whatever we pass. add(arr, 64) would return the address from arr + 64 bytes. correct. ?
I want to achieve same things with storage variables (x_slot and x_offset).. I have the following code.
uint[] storageArr;
function assembly2() public view returns (uint a, uint b, uint c) {
storageArr.push(111);
storageArr.push(222);
storageArr.push(333);
assembly {
a := sload(0)
b := sload(32)
c := sload(64)
}
}
This returns {3, 0, 0,}. The first one(slot) is 3, since it stores the length of the array. why is the second and third one 0 ?