From 0b08d11f488fa14975fbc585af639aa00d7f4c0b Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 31 Jul 2017 13:59:00 +0100 Subject: [PATCH] Add comparison with current opcodes --- EIPS/eip-145.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/EIPS/eip-145.md b/EIPS/eip-145.md index 95c84816..04f36bcd 100644 --- a/EIPS/eip-145.md +++ b/EIPS/eip-145.md @@ -37,6 +37,7 @@ Notes: - The value (`arg1`) is interpreted as an unsigned number. - The shift amount (`arg2`) is interpreted as an unsigned number. - If the shift amount (`arg2`) is greater or equal 256 the result is 0. +- This is equivalent to `SWAP1 PUSH1 2 EXP MUL`. ### `0x1c`: `SHR` (logical shift right) @@ -50,6 +51,7 @@ Notes: - The value (`arg1`) is interpreted as an unsigned number. - The shift amount (`arg2`) is interpreted as an unsigned number. - If the shift amount (`arg2`) is greater or equal 256 the result is 0. +- This is equivalent to `SWAP1 PUSH1 2 EXP DIV`. ### `0x1d`: `SAR` (arithmetic shift right) @@ -63,6 +65,7 @@ Notes: - The value (`arg1`) is interpreted as a signed number. - The shift amount (`arg2`) is interpreted as an unsigned number. - If the shift amount (`arg2`) is greater or equal 256 the result is 0 if `arg1` is non-negative or -1 if `arg1` is negative. +- This is **not** equivalent to `SWAP1 PUSH1 2 EXP SDIV`, since it rounds differently. See `SDIV(-1, 2) == 0`, while `SAR(-1, 1) == -1`. The cost of the shift instructions is set at `verylow` tier (3 gas).