I'm trying to figure out how EVM bytecode works and I created an empty contract in Remix. The assembly version looks like this:
PUSH1 0x60
PUSH1 0x40
MSTORE
CALLVALUE
ISZERO
PUSH1 0xE
JUMPI
PUSH1 0x0
DUP1
REVERT
JUMPDEST
PUSH1 0x35
DUP1
PUSH1 0x1B
PUSH1 0x0
CODECOPY
PUSH1 0x0
RETURN
STOP
PUSH1 0x60
PUSH1 0x40
MSTORE
PUSH1 0x0
DUP1
REVERT
STOP
AFAIK the first part is executed at contract creation, and the second part is the contract code itself.
What I fail to understand though is this part:
PUSH1 0x60
PUSH1 0x40
MSTORE
Why do we need to store smth in memory at the beginning of each program?