Learn EVM Opcodes III

Solidity Programming Language
2 min readMar 10, 2023

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)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Solidity Programming Language
Solidity Programming Language

Written by Solidity Programming Language

Solidity basics for beginners: Learn the fundamentals of smart contract development and build your first DApp! #Solidity #Foundry #Ethereum #Opcodes #DApps

Responses (1)

Write a response