Learning Solidity : Tutorial 12 Functional Assembly

Homepage of solidity : https://solidity.readthedocs.io/en/develop/
Remix : http://remix.ethereum.org
Source code : https://github.com/willitscale/learning-solidity

If you would like to donate some Ethereum my wallet is: 0xC8c8c3Fae80e3eD236970e1C93AcF5B91D0993e2
Many thanks!

Solidity Assembly: http://solidity.readthedocs.io/en/develop/assembly.html

Comments

BitShortener says:

Working with Hex values in this way are new to me.. I get why uint is 0x20, but Why would we mstore(add(_ptr, 0x20), _v) then return(_ptr, 0x40) for a byte array ? What about the first 32 bytes? I lose you around 15:30 onward

edit: length of the array followed by the sequential values… so if the array contains one uint then the length is 0x20, then the values (which would be one uint) would be from 0x20 to 0x40?

id test says:

Hi Sir, can you teach some knowledge about how to update the exist smart contract in Ethereum , thank you!

f j says:

Great tutorial sir keep up the good work

What's Solidity says:

Also, I was right with returning the bytes array at the end I just forgot to compile it /facepalm…

function functionalReturn() returns (bytes) {
assembly {
let ptr := add(msize(),1)
mstore(ptr, 1)
mstore(add(ptr, 0x20), 15)
return(ptr, 0x40)
}
}

What's Solidity says:

Sorry for sound levels, I switched the microphone around and it lowered my input volume.

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!