I have compiled the following Solidity code:

pragma solidity ^0.4.9;
import "./Callee.sol";

contract Caller{
  function call(address callee_address){
    Callee callee = Callee(callee_address);

This becomes the following EVM: http://pastebin.com/BeUPghsT

I do not understand the following code snippet. Only the code after address 0x1c is copied into the bytearray of the contract upon execution. So all addresses should be 0x1c lower than what is stated here.

Address 0x1c
  PUSH1 0x60
  PUSH1 0x40
  PUSH1 0x00
Address 0x24
  PUSH29 0x0100000000000000000000000000000000000000000000000000000000
Address 0x42
  PUSH4 0xf55332ab
  PUSH1 0x3a

Does the CALLDATALOAD put the address argument (callee_address) onto the stack? If so, it seems that the unknown opcode FE (a way of stopping all execution?) is called if the address does not have 0xf55332ab as its first four bytes. Is that correctly understood?

Why should the address start with 0xf55332ab? There are no checksums in Ethereum addresses, right?

Am I correct to understand that this is where a call to function lands or is this dead code?


Code execution in EVM always starts with PC=0. So the method you have called is jumped to in a switch-like code segment in the beginning of the bytecode of the EVM.

CALLDATALOAD is not the argument given to the function "call". CALLDATALOAD is the function signature which is calculated as web3.sha3('call(address)').substr(0,10) where "call" is the name of the function in this example, and "address" is the type of the argument (or the type of the parameter, if you will) that the function takes. And lo and behold! web3.sha3('initNumbers()').substr(0,10)=0xf55332ab.

Therefore 0xFE (the halt) is called if you call anything but the method "call" with the correct set of arguments on this deployed contract. In other words: The start of the contract EVM acts as a switch statement that sends you to the correct method inside the contract. This sort of structure is called a jump table.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.