0Pricing
Web3 & DApp Development Fundamentals · บทเรียน

โอปโค้ด

การดำเนินการระดับต่ำ

โอปโค้ด เป็นบทเรียน Web3 & DApp Development Fundamentals ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Web3 & DApp Development Fundamentals และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Web3 & DApp Development Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

The EVM Instruction Set

At its lowest level, the EVM runs a sequence of opcodes — single-byte instructions that each do one thing.

Understanding opcodes reveals what your Solidity actually does and where gas goes.

What Is an Opcode?

An opcode (operation code) is a one-byte command the EVM executes. Examples include ADD, MUL, PUSH1, SLOAD, and JUMP.

Each opcode has a name, a numeric value, and a fixed gas cost.

0x01 = ADD
0x02 = MUL
0x60 = PUSH1
0x54 = SLOAD
0x56 = JUMP

Stack Manipulation Opcodes

Opcodes like PUSH, POP, DUP, and SWAP manage the stack.

PUSH adds a value, POP removes one, DUP duplicates an item, and SWAP exchanges two stack positions.

PUSH1 0x0A   // [10]
DUP1         // [10, 10]
PUSH1 0x14   // [10, 10, 20]
SWAP1        // [10, 20, 10]

Arithmetic Opcodes

Arithmetic opcodes pop operands and push results: ADD, SUB, MUL, DIV, and MOD.

All math is done on 256-bit unsigned integers (with signed variants available).

PUSH1 0x09   // [9]
PUSH1 0x04   // [9, 4]
SUB          // [5]   (9 - 4)

Comparison and Logic

Opcodes like LT, GT, EQ, AND, OR, and ISZERO handle comparisons and bitwise logic.

They push 1 for true and 0 for false, which control flow then uses.

Memory and Storage Opcodes

Data movement opcodes touch the costly locations:

  • MLOAD / MSTORE — read/write memory
  • SLOAD / SSTORE — read/write storage

SSTORE is one of the most expensive opcodes.

Control Flow Opcodes

JUMP and JUMPI (conditional jump) move execution to a JUMPDEST marker.

This is how the EVM implements loops and if-statements at the bytecode level.

PUSH1 0x10   // jump target
JUMPI        // jump if top of stack != 0
// ... at offset 0x10:
JUMPDEST     // valid landing spot

Environment Opcodes

Opcodes like CALLER, CALLVALUE, ADDRESS, and TIMESTAMP expose context.

For example, CALLER pushes the address that initiated the call (this is what msg.sender compiles to).

Gas Cost per Opcode

Every opcode has a defined gas cost. Cheap ones like ADD cost 3 gas; expensive ones like SSTORE cost up to 20000.

The total gas of a transaction is the sum of all opcodes it executes.

ADD    -> 3 gas
MLOAD  -> 3 gas
SLOAD  -> 2100 gas
SSTORE -> up to 20000 gas

From Solidity to Opcodes

The Solidity compiler turns each high-level statement into many opcodes.

A single uint x = a + b; becomes PUSH, PUSH, ADD, and an MSTORE or SSTORE depending on where x lives.

Putting It Together

Opcodes are the EVM's atomic instructions for stack, arithmetic, logic, memory, storage, control flow, and environment.

Each carries a gas cost, and your Solidity ultimately becomes a stream of them.

Quick Check

Test your opcode knowledge.

Recap: Opcodes

You learned that:

  • Opcodes are one-byte EVM instructions
  • They cover the stack, arithmetic, logic, memory, storage, control flow, and environment
  • SSTORE is among the most expensive
  • Solidity compiles into many opcodes

Next: accounts and state.

คำถามที่พบบ่อย

บทเรียน “โอปโค้ด” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “โอปโค้ด” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Web3 & DApp Development Fundamentals ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Web3 & DApp Development Fundamentals มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “โอปโค้ด”

การดำเนินการระดับต่ำ คุณปฏิบัติ Web3 & DApp Development Fundamentals ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Web3 & DApp Development Fundamentals หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Web3 & DApp Development Fundamentals บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “โอปโค้ด” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Web3 & DApp Development Fundamentals นี้ได้ไหม

ได้ บทเรียน Web3 & DApp Development Fundamentals ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เครื่องเสมือน Ethereum
  2. พื้นที่จัดเก็บ หน่วยความจำ สแตก
  3. โอปโค้ด
  4. บัญชีและสถานะ
← กลับไปที่ Web3 & DApp Development Fundamentals