Change page

# 以太坊虛擬機的作業碼

💡 快速提示：要檢視整行，可以用 `[shift] + 滑鼠滾輪`在桌面上水平滾動。

00停止0halt execution
01ADD3`a, b``a + b`(u)int256 addition modulo 2**256
02MUL5`a, b``a * b`(u)int256 multiplication modulo 2**256
03SUB3`a, b``a - b`(u)int256 addition modulo 2**256
04DIV5`a, b``a // b`uint256 division
05SDIV5`a, b``a // b`int256 division
06MOD5`a, b``a % b`uint256 modulus
07SMOD5`a, b``a % b`int256 modulus
08ADDMOD8`a, b, N``(a + b) % N`(u)int256 addition modulo N
09MULMOD8`a, b, N``(a * b) % N`(u)int256 multiplication modulo N
0AEXPA1(opens in a new tab)`a, b``a ** b`uint256 exponentiation modulo 2**256
0BSIGNEXTEND5`b, x``SIGNEXTEND(x, b)`sign extend(opens in a new tab) `x` from `(b+1)` bytes to 32 bytes
0C-0Finvalid
10LT3`a, b``a < b`uint256 less-than
11GT3`a, b``a > b`uint256 greater-than
12SLT3`a, b``a < b`int256 less-than
13SGT3`a, b``a > b`int256 greater-than
14EQ3`a, b``a == b`(u)int256 equality
15ISZERO3`a``a == 0`(u)int256 iszero
16AND3`a, b``a && b`bitwise AND
17OR3`a, b``a \|\| b`bitwise OR
18XOR3`a, b``a ^ b`bitwise XOR
19NOT3`a``~a`bitwise NOT
1ABYTE3`i, x``(x >> (248 - i * 8)) && 0xFF``i`th byte of (u)int256 `x`, from the left
1BSHL3`shift, val``val << shift`shift left
1CSHR3`shift, val``val >> shift`logical shift right
1DSAR3`shift, val``val >> shift`arithmetic shift right
1E-1Finvalid
20KECCAK256A2(opens in a new tab)`ost, len``keccak256(mem[ost:ost+len-1])`keccak256
21-2Finvalid
30ADDRESS2`。``address(this)`address of executing contract
31BALANCEA5(opens in a new tab)`addr``addr.balance`balance, in wei
32ORIGIN2`。``tx.origin`address that originated the tx
33CALLER2`。``msg.sender`address of msg sender
34CALLVALUE2`。``msg.value`msg value, in wei
35CALLDATALOAD3`idx``msg.data[idx:idx+32]`read word from msg data at index `idx`
36CALLDATASIZE2`。``len(msg.data)`length of msg data, in bytes
37CALLDATACOPYA3(opens in a new tab)`dstOst, ost, len``。`mem[dstOst:dstOst+len-1] := msg.data[ost:ost+len-1]copy msg data
38CODESIZE2`。``len(this.code)`length of executing contract's code, in bytes
39CODECOPYA3(opens in a new tab)`dstOst, ost, len``。`mem[dstOst:dstOst+len-1] := this.code[ost:ost+len-1]
3AGASPRICE2`。``tx.gasprice`gas price of tx, in wei per unit gas **(opens in a new tab)
3BEXTCODESIZEA5(opens in a new tab)`addr``len(addr.code)`size of code at addr, in bytes
3CEXTCODECOPYA4(opens in a new tab)`addr, dstOst, ost, len``。`mem[dstOst:dstOst+len-1] := addr.code[ost:ost+len-1]copy code from `addr`
3DRETURNDATASIZE2`。``size`size of returned data from last external call, in bytes
3ERETURNDATACOPYA3(opens in a new tab)`dstOst, ost, len``。`mem[dstOst:dstOst+len-1] := returndata[ost:ost+len-1]copy returned data from last external call
3FEXTCODEHASHA5(opens in a new tab)`addr``hash`hash = addr.exists ? keccak256(addr.code) : 0
40BLOCKHASH20`blockNum``blockHash(blockNum)`
41COINBASE2`。``block.coinbase`address of miner of current block
42TIMESTAMP2`。``block.timestamp`timestamp of current block
43NUMBER2`。``block.number`number of current block
44PREVRANDAO2`。``randomness beacon`randomness beacon
45GASLIMIT2`。``block.gaslimit`gas limit of current block
46CHAINID2`。``chain_id`push current chain id(opens in a new tab) onto stack
47SELFBALANCE5`。``address(this).balance`balance of executing contract, in wei
48BASEFEE2`。``block.basefee`base fee of current block
49-4Finvalid
50POP2`_anon``。`remove item from top of stack and discard it
51MLOAD3*(opens in a new tab)`ost``mem[ost:ost+32]`read word from memory at offset `ost`
52MSTORE3*(opens in a new tab)`ost, val``。`mem[ost:ost+32] := valwrite a word to memory
53MSTORE83*(opens in a new tab)`ost, val``。`mem[ost] := val && 0xFFwrite a single byte to memory
54SLOADA6(opens in a new tab)`key``storage[key]`read word from storage
55SSTOREA7(opens in a new tab)`key, val``。`storage[key] := valwrite word to storage
56JUMP8`dst``。``\$pc := dst` mark that `pc` is only assigned if `dst` is a valid jumpdest
57JUMPI10`dst, condition``。``\$pc := condition ? dst : \$pc + 1`
58PC2`。``\$pc`program counter
59MSIZE2`。``len(mem)`size of memory in current execution context, in bytes
5AGAS2`。``gasRemaining`
5BJUMPDEST1mark valid jump destinationa valid jump destination for example a jump destination not inside the push data
5C-5Einvalid
5FPUSH02`。``uint8`將常數 0 推入堆疊中
60PUSH13`。``uint8`push 1-byte value onto stack
61PUSH23`。``uint16`push 2-byte value onto stack
62PUSH33`。``uint24`push 3-byte value onto stack
63PUSH43`。``uint32`push 4-byte value onto stack
64PUSH53`。``uint40`push 5-byte value onto stack
65PUSH63`。``uint48`push 6-byte value onto stack
66PUSH73`。``uint56`push 7-byte value onto stack
67PUSH83`。``uint64`push 8-byte value onto stack
68PUSH93`。``uint72`push 9-byte value onto stack
69PUSH103`。``uint80`push 10-byte value onto stack
6APUSH113`。``uint88`push 11-byte value onto stack
6BPUSH123`。``uint96`push 12-byte value onto stack
6CPUSH133`。``uint104`push 13-byte value onto stack
6DPUSH143`。``uint112`push 14-byte value onto stack
6EPUSH153`。``uint120`push 15-byte value onto stack
6FPUSH163`。``uint128`push 16-byte value onto stack
70PUSH173`。``uint136`push 17-byte value onto stack
71PUSH183`。``uint144`push 18-byte value onto stack
72PUSH193`。``uint152`push 19-byte value onto stack
73PUSH203`。``uint160`push 20-byte value onto stack
74PUSH213`。``uint168`push 21-byte value onto stack
75PUSH223`。``uint176`push 22-byte value onto stack
76PUSH233`。``uint184`push 23-byte value onto stack
77PUSH243`。``uint192`push 24-byte value onto stack
78PUSH253`。``uint200`push 25-byte value onto stack
79PUSH263`。``uint208`push 26-byte value onto stack
7APUSH273`。``uint216`push 27-byte value onto stack
7BPUSH283`。``uint224`push 28-byte value onto stack
7CPUSH293`。``uint232`push 29-byte value onto stack
7DPUSH303`。``uint240`push 30-byte value onto stack
7EPUSH313`。``uint248`push 31-byte value onto stack
7FPUSH323`。``uint256`push 32-byte value onto stack
80DUP13`a``a, a`clone 1st value on stack
81DUP23`_, a``a, _, a`clone 2nd value on stack
82DUP33`_, _, a``a, _, _, a`clone 3rd value on stack
83DUP43`_, _, _, a``a, _, _, _, a`clone 4th value on stack
84DUP53`..., a``a, ..., a`clone 5th value on stack
85DUP63`..., a``a, ..., a`clone 6th value on stack
86DUP73`..., a``a, ..., a`clone 7th value on stack
87DUP83`..., a``a, ..., a`clone 8th value on stack
88DUP93`..., a``a, ..., a`clone 9th value on stack
89DUP103`..., a``a, ..., a`clone 10th value on stack
8ADUP113`..., a``a, ..., a`clone 11th value on stack
8BDUP123`..., a``a, ..., a`clone 12th value on stack
8CDUP133`..., a``a, ..., a`clone 13th value on stack
8DDUP143`..., a``a, ..., a`clone 14th value on stack
8EDUP153`..., a``a, ..., a`clone 15th value on stack
8FDUP163`..., a``a, ..., a`clone 16th value on stack
90SWAP13`a, b``b, a`
91SWAP23`a, _, b``b, _, a`
92SWAP33`a, _, _, b``b, _, _, a`
93SWAP43`a, _, _, _, b``b, _, _, _, a`
94SWAP53`a, ..., b``b, ..., a`
95SWAP63`a, ..., b``b, ..., a`
96SWAP73`a, ..., b``b, ..., a`
97SWAP83`a, ..., b``b, ..., a`
98SWAP93`a, ..., b``b, ..., a`
99SWAP103`a, ..., b``b, ..., a`
9ASWAP113`a, ..., b``b, ..., a`
9BSWAP123`a, ..., b``b, ..., a`
9CSWAP133`a, ..., b``b, ..., a`
9DSWAP143`a, ..., b``b, ..., a`
9ESWAP153`a, ..., b``b, ..., a`
9FSWAP163`a, ..., b``b, ..., a`
A0LOG0A8(opens in a new tab)`ost, len``。`LOG0(memory[ost:ost+len-1])
A1LOG1A8(opens in a new tab)`ost, len, topic0``。`LOG1(memory[ost:ost+len-1], topic0)
A2LOG2A8(opens in a new tab)`ost, len, topic0, topic1``。`LOG1(memory[ost:ost+len-1], topic0, topic1)
A3LOG3A8(opens in a new tab)`ost, len, topic0, topic1, topic2``。`LOG1(memory[ost:ost+len-1], topic0, topic1, topic2)
A4LOG4A8(opens in a new tab)`ost, len, topic0, topic1, topic2, topic3``。`LOG1(memory[ost:ost+len-1], topic0, topic1, topic2, topic3)
A5-EFinvalid
F0CREATEA9(opens in a new tab)`val, ost, len``addr`addr = keccak256(rlp([address(this), this.nonce]))
F1CALLAA(opens in a new tab)`gas, addr, val, argOst, argLen, retOst, retLen``success`mem[retOst:retOst+retLen-1] := returndata
F2CALLCODEAA(opens in a new tab)`gas, addr, val, argOst, argLen, retOst, retLen``success`mem[retOst:retOst+retLen-1] = returndatasame as DELEGATECALL, but does not propagate original msg.sender and msg.value
F3返回0*(opens in a new tab)`ost, len``。`return mem[ost:ost+len-1]
F4DELEGATECALLAA(opens in a new tab)`gas, addr, argOst, argLen, retOst, retLen``success`mem[retOst:retOst+retLen-1] := returndata
F5CREATE2A9(opens in a new tab)`val, ost, len, salt``addr`addr = keccak256(0xff ++ address(this) ++ salt ++ keccak256(mem[ost:ost+len-1]))[12:]
F6-F9invalid
FASTATICCALLAA(opens in a new tab)`gas, addr, argOst, argLen, retOst, retLen``success`mem[retOst:retOst+retLen-1] := returndata
FB-FCinvalid
FD返回0*(opens in a new tab)`ost, len``。`revert(mem[ost:ost+len-1])
FEINVALIDAF(opens in a new tab)designated invalid opcode - EIP-141(opens in a new tab)
FFSELFDESTRUCTAB(opens in a new tab)`addr``。`

### 這篇文章對你有幫助嗎？

(opens in a new tab)(opens in a new tab)(opens in a new tab)

### 學習

• 學習中心
• 什麼是以太坊？
• 什麼是以太幣 (ETH)？
• 以太坊錢包
• 什麼是 Web3？
• 智慧型合約
• Gas fees
• 執行節點
• 以太坊安全及詐騙預防
• 測驗中心
• 以太坊詞彙表