owned this note
owned this note
Published
Linked with GitHub
# Yul
$$
\begin{aligned}
&\begin{array}{|l|l|l|l|}
\hline & \text { dialect: not specified } & \text { dialect: evm } & \text { dialect: ewasm } \\
\hline \text {--strict-assembly } & \text { ewasm } & \text { strict assembly } & \text { ewasm } \\
\hline \text {--yul } & \text { (error) } & \text { strict assembly } & \text { ewasm } \\
\hline \text {--assemble } & \text { (error) } & \text { strict assembly } & \text { ewasm } \\
\hline
\end{array}\\
&\text { Machine: evm or evm15 }\\
&\begin{array}{|l|l|l|l|}
\hline & \text { dialect: not specified } & \text { dialect: evm } & \text { dialect: ewasm } \\
\hline \text {--strict-assembly } & \text { strict assembly } & \text { strict assembly } & \text { (error) } \\
\hline \text {--yul } & \text { typed Yul } & \text { strict assembly } & \text { (error) } \\
\hline \text { - -assemble } & \text { loose assembly } & \text { strict assembly } & \text { (error) } \\
\hline
\end{array}
\end{aligned}
$$
| | dialect: not specified | dialect: evm | dialect: ewasm |
| :--- | :--- | :--- | :--- |
| --strict-assembly | ewasm | strict assembly | ewasm |
| --yul | (error) | strict assembly | ewasm |
| - -assemble | (error) | strict assembly | ewasm |
| | dialect: not specified | dialect: evm | dialect: ewasm |
| :--- | :--- | :--- | :--- |
| --strict-assembly | strict assembly | strict assembly | (error) |
| --yul | typed Yul | strict assembly | (error) |
| - -assemble | loose assembly | strict assembly | (error) |
```cpp
add(#A, #B) == add!(A, B)
mul(#A, #B) == mul!(A, B)
byte(#A, #B) == 0 iff gte!(A, div!(wordsize!(), 8))
byte(#A, #B) == shr!(B, and!(mul!(8, sub!(sub!(div!(wordsize!(), 8), 1), A)), 0xff)) iff lt!(A, div!(wordsize!(), 8))
shl(#A, #B) == 0 iff gte!(A, wordsize!())
shl(#A, #B) == shl!(A, B)
shr(#A, #B) == 0 iff gte!(A, wordsize!())
shr(#A, #B) == shr!(A, B)
sub(not!(0), X) == not!(0)
mul(X, not!(0)) == sub(0, X)
mul(not!(0), X) == sub(0, X)
and(X, not!(0)) == X
and(not!(0), X) == X
eq(X, 0) == iszero(X)
eq(0, X) == iszero(X)
gt(X, 0) == iszero(iszero(X))
lt(0, X) == iszero(iszero(X))
gt(X, not!(0)) == 0
lt(not!(0), X) == 0
and(byte(X, Y), 0xff) == byte(X, Y)
byte(sub!(div!(wordsize!(), 8), 1), X) == and(X, 0xff)
not(not(X) == X
xor(X, xor(X, Y)) == Y
or(not(X), X) == not!(0)
and(and(X, Y), Y) == and(X, Y)
mod(X, 1) == and(X, 0)
mod(X, 2) == and(X, 1)
mod(X, 4) == and(X, 3)
mod(X, shl!(1, K)) == and(X, sub!(shl!(1, K), 1))) iff and!(gte!(K, 0), lte!(K, wordsize!()))
byte(#A, shr(#B, X)) == 0 iff lt!(A, div!(B, 8))
and(address(), sub!(shl!(1, 160), 1)) == address()
and(caller(), sub!(shl!(1, 160), 1)) == caller()
and(origin(), sub!(shl!(1, 160), 1)) == origin()
and(coinbase(), sub!(shl!(1, 160), 1)) == coinbase()
iszero(iszero(eq(X, Y))) == eq(X, Y)
iszero(iszero(lt(X, Y))) == lt(X, Y)
iszero(iszero(slt(X, Y))) == slt(X, Y)
iszero(iszero(gt(X, Y))) == gt(X, Y)
iszero(iszero(sgt(X, Y))) == sgt(X, Y)
iszero(iszero(iszero(X))) == iszero(X)
iszero(xor(X, Y)) == eq(X, Y)
byte(#A, shr(#B, X)) == 0 iff lt!(A, div!(B, 8))
sub(X, #A) == add(X, sub!(0, A))
sub(add(X, #A), Y) == add(sub(X, Y), A)
[@evm hasSelfbalance]
balance(address()) == selfbalance()
exp(0, X) == iszero(X)
exp(1, X) == 1
[@evm hasBitwiseShifting]
exp(2, X) == shl(X, 1)
exp(-1, X) == sub(iszero(and(X, 1)), and(X, 1))