I am learning the inline assembly in solidity, i ve found the function mload(0x40)
i am confused whith what this function does? did it reserve 4 Slot/word in memory or did it load the data stored in the address 0X40 or what?
[Ethereum] understanding mload assembly function
assemblysolidity
Best Answer
mload(0xAB)
Loads the word (32byte) located at the memory address 0xAB. e.gmload(0x60)
loads the word located at 0x60 memory address.let's code to understand more :
this results in the flowing memory state :
This previous code stores tow strings (two memory words 32bytes each) in the free memory space. The destinations memory addresses are obtained by adding an offset of 0bytes for the first and of 0x20 for the second to the free memory pointer address(located in the memory address 0x40).
in the EVM The 6 first words in the memory are reserved and the 0x40-0x50 memory words are allocated to the free memory pointer.
Details : mload and mstore are defined in details in the yellow paper :
[a...b) signifies the bytes of memory starting at position a up to (excluding) position b. however b] means b included