Learn EVM Opcodes III

--

Learn EVM Opcodes III

We will perform various manipulations on the largest number on the EVM. Thanks to this study, you will better understand the working (clock) logic of EVM.

The largest maximum value and ADD Opcode

We have “1” in the stack and we add the largest maximum value you can send to EVM is 32 bytes sized value. What happens if we add “1” to this value?

PUSH32 0xFFFFFFFFFFFFF………..FFFFFFFFFFFFFFFFFFFFFFF
PUSH1 1
ADD

ADD OPCODE

1+ 0xFFFFFFFFFFFFF………..FFFFFFFFFFFFFFFFFFFFFFF

We will add the largest number on the EVM to the value “1” and see the result.

Execute it

The result is “0”.

Could you explain why the result is “0” ? The largest maximum value you can send to EVM is 32 bytes sized value and the value after this value is “0” which is the initial value of the array. You can think of it like a clock. This illustration explains this logic.

ADD OPCODE with maximum sized value

The largest maximum value and SUB Opcode

PUSH32 0xFFFFFFFFFFFFF………..FFFFFFFFFFFFFFFFFFFFFFF
PUSH1 1
SUB

SUB OPCODE

In our new operation, we will subtract from “1” the largest maximum value. What is the result?

1- 0xFFFFFFFFFFFFF………..FFFFFFFFFFFFFFFFFFFFFFF

Execute it

The result is “2”.

What happens if you try to subtract 1 from the largest number in evm ? Let’s consider the clock example. Starting from 1, you make one full turn and reach 2.

SUB OPCODE with maximum sized value

Thank you.

Associate Professor Engin YILMAZ (VeriDelisi)

--

--