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
1+ 0xFFFFFFFFFFFFF………..FFFFFFFFFFFFFFFFFFFFFFF
We will add the largest number on the EVM to the value “1” and see the result.
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.
The largest maximum value and SUB Opcode
PUSH32 0xFFFFFFFFFFFFF………..FFFFFFFFFFFFFFFFFFFFFFF
PUSH1 1
SUB
In our new operation, we will subtract from “1” the largest maximum value. What is the result?
1- 0xFFFFFFFFFFFFF………..FFFFFFFFFFFFFFFFFFFFFFF
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.
Thank you.