Merge pull request #3604 from ethereum/docs-update

Introduce VM version ('hard fork') column for assembly opcodes
This commit is contained in:
chriseth 2018-02-27 11:58:32 +01:00 committed by GitHub
commit 9c31a0d8f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 242 additions and 239 deletions

View File

@ -153,6 +153,8 @@ If an opcode takes arguments (always from the top of the stack), they are given
Note that the order of arguments can be seen to be reversed in non-functional style (explained below). Note that the order of arguments can be seen to be reversed in non-functional style (explained below).
Opcodes marked with ``-`` do not push an item onto the stack, those marked with ``*`` are Opcodes marked with ``-`` do not push an item onto the stack, those marked with ``*`` are
special and all others push exactly one item onto the stack. special and all others push exactly one item onto the stack.
Opcodes marked with ``F``, ``H``, ``B`` or ``C`` are present since Frontier, Homestead, Byzantium or Constantinople, respectively.
Constantinople is still in planning and all instructions marked as such will result in an invalid instruction exception.
In the following, ``mem[a...b)`` signifies the bytes of memory starting at position ``a`` up to In the following, ``mem[a...b)`` signifies the bytes of memory starting at position ``a`` up to
(excluding) position ``b`` and ``storage[p]`` signifies the storage contents at position ``p``. (excluding) position ``b`` and ``storage[p]`` signifies the storage contents at position ``p``.
@ -161,167 +163,167 @@ The opcodes ``pushi`` and ``jumpdest`` cannot be used directly.
In the grammar, opcodes are represented as pre-defined identifiers. In the grammar, opcodes are represented as pre-defined identifiers.
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| Instruction | | Explanation | | Instruction | | | Explanation |
+=========================+======+=================================================================+ +=========================+=====+===+=================================================================+
| stop + `-` | stop execution, identical to return(0,0) | | stop + `-` | F | stop execution, identical to return(0,0) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| add(x, y) | | x + y | | add(x, y) | | F | x + y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| sub(x, y) | | x - y | | sub(x, y) | | F | x - y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| mul(x, y) | | x * y | | mul(x, y) | | F | x * y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| div(x, y) | | x / y | | div(x, y) | | F | x / y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| sdiv(x, y) | | x / y, for signed numbers in two's complement | | sdiv(x, y) | | F | x / y, for signed numbers in two's complement |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| mod(x, y) | | x % y | | mod(x, y) | | F | x % y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| smod(x, y) | | x % y, for signed numbers in two's complement | | smod(x, y) | | F | x % y, for signed numbers in two's complement |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| exp(x, y) | | x to the power of y | | exp(x, y) | | F | x to the power of y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| not(x) | | ~x, every bit of x is negated | | not(x) | | F | ~x, every bit of x is negated |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| lt(x, y) | | 1 if x < y, 0 otherwise | | lt(x, y) | | F | 1 if x < y, 0 otherwise |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| gt(x, y) | | 1 if x > y, 0 otherwise | | gt(x, y) | | F | 1 if x > y, 0 otherwise |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| slt(x, y) | | 1 if x < y, 0 otherwise, for signed numbers in two's complement | | slt(x, y) | | F | 1 if x < y, 0 otherwise, for signed numbers in two's complement |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| sgt(x, y) | | 1 if x > y, 0 otherwise, for signed numbers in two's complement | | sgt(x, y) | | F | 1 if x > y, 0 otherwise, for signed numbers in two's complement |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| eq(x, y) | | 1 if x == y, 0 otherwise | | eq(x, y) | | F | 1 if x == y, 0 otherwise |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| iszero(x) | | 1 if x == 0, 0 otherwise | | iszero(x) | | F | 1 if x == 0, 0 otherwise |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| and(x, y) | | bitwise and of x and y | | and(x, y) | | F | bitwise and of x and y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| or(x, y) | | bitwise or of x and y | | or(x, y) | | F | bitwise or of x and y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| xor(x, y) | | bitwise xor of x and y | | xor(x, y) | | F | bitwise xor of x and y |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| byte(n, x) | | nth byte of x, where the most significant byte is the 0th byte | | byte(n, x) | | F | nth byte of x, where the most significant byte is the 0th byte |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| addmod(x, y, m) | | (x + y) % m with arbitrary precision arithmetics | | addmod(x, y, m) | | F | (x + y) % m with arbitrary precision arithmetics |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| mulmod(x, y, m) | | (x * y) % m with arbitrary precision arithmetics | | mulmod(x, y, m) | | F | (x * y) % m with arbitrary precision arithmetics |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| signextend(i, x) | | sign extend from (i*8+7)th bit counting from least significant | | signextend(i, x) | | F | sign extend from (i*8+7)th bit counting from least significant |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| keccak256(p, n) | | keccak(mem[p...(p+n))) | | keccak256(p, n) | | F | keccak(mem[p...(p+n))) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| sha3(p, n) | | keccak(mem[p...(p+n))) | | sha3(p, n) | | F | keccak(mem[p...(p+n))) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| jump(label) | `-` | jump to label / code position | | jump(label) | `-` | F | jump to label / code position |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| jumpi(label, cond) | `-` | jump to label if cond is nonzero | | jumpi(label, cond) | `-` | F | jump to label if cond is nonzero |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| pc | | current position in code | | pc | | F | current position in code |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| pop(x) | `-` | remove the element pushed by x | | pop(x) | `-` | F | remove the element pushed by x |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| dup1 ... dup16 | | copy ith stack slot to the top (counting from top) | | dup1 ... dup16 | | F | copy ith stack slot to the top (counting from top) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| swap1 ... swap16 | `*` | swap topmost and ith stack slot below it | | swap1 ... swap16 | `*` | F | swap topmost and ith stack slot below it |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| mload(p) | | mem[p..(p+32)) | | mload(p) | | F | mem[p..(p+32)) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| mstore(p, v) | `-` | mem[p..(p+32)) := v | | mstore(p, v) | `-` | F | mem[p..(p+32)) := v |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| mstore8(p, v) | `-` | mem[p] := v & 0xff (only modifies a single byte) | | mstore8(p, v) | `-` | F | mem[p] := v & 0xff (only modifies a single byte) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| sload(p) | | storage[p] | | sload(p) | | F | storage[p] |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| sstore(p, v) | `-` | storage[p] := v | | sstore(p, v) | `-` | F | storage[p] := v |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| msize | | size of memory, i.e. largest accessed memory index | | msize | | F | size of memory, i.e. largest accessed memory index |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| gas | | gas still available to execution | | gas | | F | gas still available to execution |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| address | | address of the current contract / execution context | | address | | F | address of the current contract / execution context |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| balance(a) | | wei balance at address a | | balance(a) | | F | wei balance at address a |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| caller | | call sender (excluding ``delegatecall``) | | caller | | F | call sender (excluding ``delegatecall``) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| callvalue | | wei sent together with the current call | | callvalue | | F | wei sent together with the current call |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| calldataload(p) | | call data starting from position p (32 bytes) | | calldataload(p) | | F | call data starting from position p (32 bytes) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| calldatasize | | size of call data in bytes | | calldatasize | | F | size of call data in bytes |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| calldatacopy(t, f, s) | `-` | copy s bytes from calldata at position f to mem at position t | | calldatacopy(t, f, s) | `-` | F | copy s bytes from calldata at position f to mem at position t |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| codesize | | size of the code of the current contract / execution context | | codesize | | F | size of the code of the current contract / execution context |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| codecopy(t, f, s) | `-` | copy s bytes from code at position f to mem at position t | | codecopy(t, f, s) | `-` | F | copy s bytes from code at position f to mem at position t |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| extcodesize(a) | | size of the code at address a | | extcodesize(a) | | F | size of the code at address a |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| extcodecopy(a, t, f, s) | `-` | like codecopy(t, f, s) but take code at address a | | extcodecopy(a, t, f, s) | `-` | F | like codecopy(t, f, s) but take code at address a |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| returndatasize | | size of the last returndata | | returndatasize | | B | size of the last returndata |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| returndatacopy(t, f, s) | `-` | copy s bytes from returndata at position f to mem at position t | | returndatacopy(t, f, s) | `-` | B | copy s bytes from returndata at position f to mem at position t |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| create(v, p, s) | | create new contract with code mem[p..(p+s)) and send v wei | | create(v, p, s) | | F | create new contract with code mem[p..(p+s)) and send v wei |
| | | and return the new address | | | | | and return the new address |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| create2(v, n, p, s) | | create new contract with code mem[p..(p+s)) at address | | create2(v, n, p, s) | | C | create new contract with code mem[p..(p+s)) at address |
| | | keccak256(<address> . n . keccak256(mem[p..(p+s))) and send v | | | | | keccak256(<address> . n . keccak256(mem[p..(p+s))) and send v |
| | | wei and return the new address | | | | | wei and return the new address |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| call(g, a, v, in, | | call contract at address a with input mem[in..(in+insize)) | | call(g, a, v, in, | | F | call contract at address a with input mem[in..(in+insize)) |
| insize, out, outsize) | | providing g gas and v wei and output area | | insize, out, outsize) | | | providing g gas and v wei and output area |
| | | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) | | | | | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) |
| | | and 1 on success | | | | | and 1 on success |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| callcode(g, a, v, in, | | identical to ``call`` but only use the code from a and stay | | callcode(g, a, v, in, | | F | identical to ``call`` but only use the code from a and stay |
| insize, out, outsize) | | in the context of the current contract otherwise | | insize, out, outsize) | | | in the context of the current contract otherwise |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| delegatecall(g, a, in, | | identical to ``callcode`` but also keep ``caller`` | | delegatecall(g, a, in, | | H | identical to ``callcode`` but also keep ``caller`` |
| insize, out, outsize) | | and ``callvalue`` | | insize, out, outsize) | | | and ``callvalue`` |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| staticcall(g, a, in, | | identical to ``call(g, a, 0, in, insize, out, outsize)`` but do | | staticcall(g, a, in, | | B | identical to ``call(g, a, 0, in, insize, out, outsize)`` but do |
| insize, out, outsize) | | not allow state modifications | | insize, out, outsize) | | | not allow state modifications |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| return(p, s) | `-` | end execution, return data mem[p..(p+s)) | | return(p, s) | `-` | F | end execution, return data mem[p..(p+s)) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| revert(p, s) | `-` | end execution, revert state changes, return data mem[p..(p+s)) | | revert(p, s) | `-` | B | end execution, revert state changes, return data mem[p..(p+s)) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| selfdestruct(a) | `-` | end execution, destroy current contract and send funds to a | | selfdestruct(a) | `-` | F | end execution, destroy current contract and send funds to a |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| invalid | `-` | end execution with invalid instruction | | invalid | `-` | F | end execution with invalid instruction |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| log0(p, s) | `-` | log without topics and data mem[p..(p+s)) | | log0(p, s) | `-` | F | log without topics and data mem[p..(p+s)) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| log1(p, s, t1) | `-` | log with topic t1 and data mem[p..(p+s)) | | log1(p, s, t1) | `-` | F | log with topic t1 and data mem[p..(p+s)) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| log2(p, s, t1, t2) | `-` | log with topics t1, t2 and data mem[p..(p+s)) | | log2(p, s, t1, t2) | `-` | F | log with topics t1, t2 and data mem[p..(p+s)) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| log3(p, s, t1, t2, t3) | `-` | log with topics t1, t2, t3 and data mem[p..(p+s)) | | log3(p, s, t1, t2, t3) | `-` | F | log with topics t1, t2, t3 and data mem[p..(p+s)) |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| log4(p, s, t1, t2, t3, | `-` | log with topics t1, t2, t3, t4 and data mem[p..(p+s)) | | log4(p, s, t1, t2, t3, | `-` | F | log with topics t1, t2, t3, t4 and data mem[p..(p+s)) |
| t4) | | | | t4) | | | |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| origin | | transaction sender | | origin | | F | transaction sender |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| gasprice | | gas price of the transaction | | gasprice | | F | gas price of the transaction |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| blockhash(b) | | hash of block nr b - only for last 256 blocks excluding current | | blockhash(b) | | F | hash of block nr b - only for last 256 blocks excluding current |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| coinbase | | current mining beneficiary | | coinbase | | F | current mining beneficiary |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| timestamp | | timestamp of the current block in seconds since the epoch | | timestamp | | F | timestamp of the current block in seconds since the epoch |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| number | | current block number | | number | | F | current block number |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| difficulty | | difficulty of the current block | | difficulty | | F | difficulty of the current block |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
| gaslimit | | block gas limit of the current block | | gaslimit | | F | block gas limit of the current block |
+-------------------------+------+-----------------------------------------------------------------+ +-------------------------+-----+---+-----------------------------------------------------------------+
Literals Literals
-------- --------
@ -378,8 +380,8 @@ Functions external to inline assembly can also be accessed: The assembly will
push their entry label (with virtual function resolution applied). The calling semantics push their entry label (with virtual function resolution applied). The calling semantics
in solidity are: in solidity are:
- the caller pushes return label, arg1, arg2, ..., argn - the caller pushes ``return label``, ``arg1``, ``arg2``, ..., ``argn``
- the call returns with ret1, ret2, ..., retm - the call returns with ``ret1``, ``ret2``, ..., ``retm``
This feature is still a bit cumbersome to use, because the stack offset essentially This feature is still a bit cumbersome to use, because the stack offset essentially
changes during the call, and thus references to local variables will be wrong. changes during the call, and thus references to local variables will be wrong.

View File

@ -320,168 +320,169 @@ The following functions must be available:
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------------------+
| *Arithmetics* | | *Arithmetics* |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| addu256(x:u256, y:u256) -> z:u256 | x + y | | addu256(x:u256, y:u256) -> z:u256 | x + y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| subu256(x:u256, y:u256) -> z:u256 | x - y | | subu256(x:u256, y:u256) -> z:u256 | x - y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| mulu256(x:u256, y:u256) -> z:u256 | x * y | | mulu256(x:u256, y:u256) -> z:u256 | x * y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| divu256(x:u256, y:u256) -> z:u256 | x / y | | divu256(x:u256, y:u256) -> z:u256 | x / y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| divs256(x:s256, y:s256) -> z:s256 | x / y, for signed numbers in two's complement | | divs256(x:s256, y:s256) -> z:s256 | x / y, for signed numbers in two's complement |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| modu256(x:u256, y:u256) -> z:u256 | x % y | | modu256(x:u256, y:u256) -> z:u256 | x % y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| mods256(x:s256, y:s256) -> z:s256 | x % y, for signed numbers in two's complement | | mods256(x:s256, y:s256) -> z:s256 | x % y, for signed numbers in two's complement |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| signextendu256(i:u256, x:u256) -> z:u256 | sign extend from (i*8+7)th bit counting from least significant | | signextendu256(i:u256, x:u256) -> z:u256 | sign extend from (i*8+7)th bit counting from least significant |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| expu256(x:u256, y:u256) -> z:u256 | x to the power of y | | expu256(x:u256, y:u256) -> z:u256 | x to the power of y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| addmodu256(x:u256, y:u256, m:u256) -> z:u256| (x + y) % m with arbitrary precision arithmetics | | addmodu256(x:u256, y:u256, m:u256) -> z:u256| (x + y) % m with arbitrary precision arithmetics |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| mulmodu256(x:u256, y:u256, m:u256) -> z:u256| (x * y) % m with arbitrary precision arithmetics | | mulmodu256(x:u256, y:u256, m:u256) -> z:u256| (x * y) % m with arbitrary precision arithmetics |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| ltu256(x:u256, y:u256) -> z:bool | 1 if x < y, 0 otherwise | | ltu256(x:u256, y:u256) -> z:bool | 1 if x < y, 0 otherwise |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| gtu256(x:u256, y:u256) -> z:bool | 1 if x > y, 0 otherwise | | gtu256(x:u256, y:u256) -> z:bool | 1 if x > y, 0 otherwise |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| sltu256(x:s256, y:s256) -> z:bool | 1 if x < y, 0 otherwise, for signed numbers in two's complement | | sltu256(x:s256, y:s256) -> z:bool | 1 if x < y, 0 otherwise, for signed numbers in two's complement |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| sgtu256(x:s256, y:s256) -> z:bool | 1 if x > y, 0 otherwise, for signed numbers in two's complement | | sgtu256(x:s256, y:s256) -> z:bool | 1 if x > y, 0 otherwise, for signed numbers in two's complement |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| equ256(x:u256, y:u256) -> z:bool | 1 if x == y, 0 otherwise | | equ256(x:u256, y:u256) -> z:bool | 1 if x == y, 0 otherwise |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| notu256(x:u256) -> z:u256 | ~x, every bit of x is negated | | notu256(x:u256) -> z:u256 | ~x, every bit of x is negated |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| andu256(x:u256, y:u256) -> z:u256 | bitwise and of x and y | | andu256(x:u256, y:u256) -> z:u256 | bitwise and of x and y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| oru256(x:u256, y:u256) -> z:u256 | bitwise or of x and y | | oru256(x:u256, y:u256) -> z:u256 | bitwise or of x and y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| xoru256(x:u256, y:u256) -> z:u256 | bitwise xor of x and y | | xoru256(x:u256, y:u256) -> z:u256 | bitwise xor of x and y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| shlu256(x:u256, y:u256) -> z:u256 | logical left shift of x by y | | shlu256(x:u256, y:u256) -> z:u256 | logical left shift of x by y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| shru256(x:u256, y:u256) -> z:u256 | logical right shift of x by y | | shru256(x:u256, y:u256) -> z:u256 | logical right shift of x by y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| saru256(x:u256, y:u256) -> z:u256 | arithmetic right shift of x by y | | saru256(x:u256, y:u256) -> z:u256 | arithmetic right shift of x by y |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| byte(n:u256, x:u256) -> v:u256 | nth byte of x, where the most significant byte is the 0th byte | | byte(n:u256, x:u256) -> v:u256 | nth byte of x, where the most significant byte is the 0th byte |
| Cannot this be just replaced by and256(shr256(n, x), 0xff) and let it be optimised out by the EVM backend? | | | Cannot this be just replaced by and256(shr256(n, x), 0xff) and |
+---------------------------------------------------------------------------------------------------------------+ | | let it be optimised out by the EVM backend? |
+---------------------------------------------+-----------------------------------------------------------------+
| *Memory and storage* | | *Memory and storage* |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| mload(p:u256) -> v:u256 | mem[p..(p+32)) | | mload(p:u256) -> v:u256 | mem[p..(p+32)) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| mstore(p:u256, v:u256) | mem[p..(p+32)) := v | | mstore(p:u256, v:u256) | mem[p..(p+32)) := v |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| mstore8(p:u256, v:u256) | mem[p] := v & 0xff - only modifies a single byte | | mstore8(p:u256, v:u256) | mem[p] := v & 0xff - only modifies a single byte |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| sload(p:u256) -> v:u256 | storage[p] | | sload(p:u256) -> v:u256 | storage[p] |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| sstore(p:u256, v:u256) | storage[p] := v | | sstore(p:u256, v:u256) | storage[p] := v |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| msize() -> size:u256 | size of memory, i.e. largest accessed memory index, albeit due | | msize() -> size:u256 | size of memory, i.e. largest accessed memory index, albeit due |
| | due to the memory extension function, which extends by words, | | | due to the memory extension function, which extends by words, |
| | this will always be a multiple of 32 bytes | | | this will always be a multiple of 32 bytes |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| *Execution control* | | *Execution control* |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| create(v:u256, p:u256, s:u256) | create new contract with code mem[p..(p+s)) and send v wei | | create(v:u256, p:u256, s:u256) | create new contract with code mem[p..(p+s)) and send v wei |
| | and return the new address | | | and return the new address |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| call(g:u256, a:u256, v:u256, in:u256, | call contract at address a with input mem[in..(in+insize)) | | call(g:u256, a:u256, v:u256, in:u256, | call contract at address a with input mem[in..(in+insize)) |
| insize:u256, out:u256, | providing g gas and v wei and output area | | insize:u256, out:u256, | providing g gas and v wei and output area |
| outsize:u256) | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) | | outsize:u256) | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) |
| -> r:u256 | and 1 on success | | -> r:u256 | and 1 on success |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| callcode(g:u256, a:u256, v:u256, in:u256, | identical to ``call`` but only use the code from a | | callcode(g:u256, a:u256, v:u256, in:u256, | identical to ``call`` but only use the code from a |
| insize:u256, out:u256, | and stay in the context of the | | insize:u256, out:u256, | and stay in the context of the |
| outsize:u256) -> r:u256 | current contract otherwise | | outsize:u256) -> r:u256 | current contract otherwise |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| delegatecall(g:u256, a:u256, in:u256, | identical to ``callcode``, | | delegatecall(g:u256, a:u256, in:u256, | identical to ``callcode``, |
| insize:u256, out:u256, | but also keep ``caller`` | | insize:u256, out:u256, | but also keep ``caller`` |
| outsize:u256) -> r:u256 | and ``callvalue`` | | outsize:u256) -> r:u256 | and ``callvalue`` |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| stop() | stop execution, identical to return(0,0) | | stop() | stop execution, identical to return(0,0) |
| Perhaps it would make sense retiring this as it equals to return(0,0). It can be an optimisation by the EVM | | | Perhaps it would make sense retiring this as it equals to |
| backend. | | | return(0,0). It can be an optimisation by the EVM backend. |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| abort() | abort (equals to invalid instruction on EVM) | | abort() | abort (equals to invalid instruction on EVM) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| return(p:u256, s:u256) | end execution, return data mem[p..(p+s)) | | return(p:u256, s:u256) | end execution, return data mem[p..(p+s)) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| revert(p:u256, s:u256) | end execution, revert state changes, return data mem[p..(p+s)) | | revert(p:u256, s:u256) | end execution, revert state changes, return data mem[p..(p+s)) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| selfdestruct(a:u256) | end execution, destroy current contract and send funds to a | | selfdestruct(a:u256) | end execution, destroy current contract and send funds to a |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| log0(p:u256, s:u256) | log without topics and data mem[p..(p+s)) | | log0(p:u256, s:u256) | log without topics and data mem[p..(p+s)) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| log1(p:u256, s:u256, t1:u256) | log with topic t1 and data mem[p..(p+s)) | | log1(p:u256, s:u256, t1:u256) | log with topic t1 and data mem[p..(p+s)) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| log2(p:u256, s:u256, t1:u256, t2:u256) | log with topics t1, t2 and data mem[p..(p+s)) | | log2(p:u256, s:u256, t1:u256, t2:u256) | log with topics t1, t2 and data mem[p..(p+s)) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| log3(p:u256, s:u256, t1:u256, t2:u256, | log with topics t, t2, t3 and data mem[p..(p+s)) | | log3(p:u256, s:u256, t1:u256, t2:u256, | log with topics t, t2, t3 and data mem[p..(p+s)) |
| t3:u256) | | | t3:u256) | |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| log4(p:u256, s:u256, t1:u256, t2:u256, | log with topics t1, t2, t3, t4 and data mem[p..(p+s)) | | log4(p:u256, s:u256, t1:u256, t2:u256, | log with topics t1, t2, t3, t4 and data mem[p..(p+s)) |
| t3:u256, t4:u256) | | | t3:u256, t4:u256) | |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| *State queries* | | *State queries* |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| blockcoinbase() -> address:u256 | current mining beneficiary | | blockcoinbase() -> address:u256 | current mining beneficiary |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| blockdifficulty() -> difficulty:u256 | difficulty of the current block | | blockdifficulty() -> difficulty:u256 | difficulty of the current block |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| blockgaslimit() -> limit:u256 | block gas limit of the current block | | blockgaslimit() -> limit:u256 | block gas limit of the current block |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| blockhash(b:u256) -> hash:u256 | hash of block nr b - only for last 256 blocks excluding current | | blockhash(b:u256) -> hash:u256 | hash of block nr b - only for last 256 blocks excluding current |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| blocknumber() -> block:u256 | current block number | | blocknumber() -> block:u256 | current block number |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| blocktimestamp() -> timestamp:u256 | timestamp of the current block in seconds since the epoch | | blocktimestamp() -> timestamp:u256 | timestamp of the current block in seconds since the epoch |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| txorigin() -> address:u256 | transaction sender | | txorigin() -> address:u256 | transaction sender |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| txgasprice() -> price:u256 | gas price of the transaction | | txgasprice() -> price:u256 | gas price of the transaction |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| gasleft() -> gas:u256 | gas still available to execution | | gasleft() -> gas:u256 | gas still available to execution |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| balance(a:u256) -> v:u256 | wei balance at address a | | balance(a:u256) -> v:u256 | wei balance at address a |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| this() -> address:u256 | address of the current contract / execution context | | this() -> address:u256 | address of the current contract / execution context |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| caller() -> address:u256 | call sender (excluding delegatecall) | | caller() -> address:u256 | call sender (excluding delegatecall) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| callvalue() -> v:u256 | wei sent together with the current call | | callvalue() -> v:u256 | wei sent together with the current call |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| calldataload(p:u256) -> v:u256 | call data starting from position p (32 bytes) | | calldataload(p:u256) -> v:u256 | call data starting from position p (32 bytes) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| calldatasize() -> v:u256 | size of call data in bytes | | calldatasize() -> v:u256 | size of call data in bytes |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| calldatacopy(t:u256, f:u256, s:u256) | copy s bytes from calldata at position f to mem at position t | | calldatacopy(t:u256, f:u256, s:u256) | copy s bytes from calldata at position f to mem at position t |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| codesize() -> size:u256 | size of the code of the current contract / execution context | | codesize() -> size:u256 | size of the code of the current contract / execution context |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| codecopy(t:u256, f:u256, s:u256) | copy s bytes from code at position f to mem at position t | | codecopy(t:u256, f:u256, s:u256) | copy s bytes from code at position f to mem at position t |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| extcodesize(a:u256) -> size:u256 | size of the code at address a | | extcodesize(a:u256) -> size:u256 | size of the code at address a |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| extcodecopy(a:u256, t:u256, f:u256, s:u256) | like codecopy(t, f, s) but take code at address a | | extcodecopy(a:u256, t:u256, f:u256, s:u256) | like codecopy(t, f, s) but take code at address a |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| *Others* | | *Others* |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| discardu256(unused:u256) | discard value | | discardu256(unused:u256) | discard value |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| splitu256tou64(x:u256) -> (x1:u64, x2:u64, | split u256 to four u64's | | splitu256tou64(x:u256) -> (x1:u64, x2:u64, | split u256 to four u64's |
| x3:u64, x4:u64) | | | x3:u64, x4:u64) | |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| combineu64tou256(x1:u64, x2:u64, x3:u64, | combine four u64's into a single u256 | | combineu64tou256(x1:u64, x2:u64, x3:u64, | combine four u64's into a single u256 |
| x4:u64) -> (x:u256) | | | x4:u64) -> (x:u256) | |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
| sha3(p:u256, s:u256) -> v:u256 | keccak(mem[p...(p+s))) | | sha3(p:u256, s:u256) -> v:u256 | keccak(mem[p...(p+s))) |
+---------------------------------------------------------------------------------------------------------------+ +---------------------------------------------+-----------------------------------------------------------------+
Backends Backends
-------- --------