ethereumsolidityevm

How does the opcode JUMP work in the EVM Stack?


I'm following along on the "Advanced Solidity" tutorial here.

I ran into an example I'm having trouble understanding. example image

In this example, why does JUMP affect the state of the stack? I expected it to only affect the program counter.

(i.e. I would expect after JUMP, at PC: 11, the length of the stack would be 3, not 2. The JUMP comes after PUSH 0x0B.)

Thanks.


Solution

  • Just to refer to the original docs. As stated in the yellow paper :

    0x56 JUMP 1 0 Alter the program counter

    Where 1 is the number of items taken out of the stack, 0 the number of items returned. So in your case JUMP removes '0b' from the stack and use it as the destination (PC = 11 = 0x0b).