diff --git a/EIPS/eip-145.md b/EIPS/eip-145.md index 6cd270c3..15fb26ae 100644 --- a/EIPS/eip-145.md +++ b/EIPS/eip-145.md @@ -79,7 +79,254 @@ The newly introduced instructions have no effect on bytecode created in the past ## Test Cases -TBA +### `SHL` (shift left) + +1. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0x00 + SHL + --- + 0x0000000000000000000000000000000000000000000000000000000000000001 + ``` +2. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0x01 + SHL + --- + 0x0000000000000000000000000000000000000000000000000000000000000002 + ``` +3. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0xff + SHL + --- + 0x8000000000000000000000000000000000000000000000000000000000000000 + ``` +4. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0x0100 + SHL + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +5. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0x0101 + SHL + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +6. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x00 + SHL + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +7. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x01 + SHL + --- + 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe + ``` +8. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0xff + SHL + --- + 0x8000000000000000000000000000000000000000000000000000000000000000 + ``` +9. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x0100 + SHL + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +10. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x01 + SHL + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` + + +### `SHR` (logical shift right) + +1. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0x00 + SHR + --- + 0x0000000000000000000000000000000000000000000000000000000000000001 + ``` +2. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0x01 + SHR + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +3. ``` + PUSH 0x8000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x01 + SHR + --- + 0x4000000000000000000000000000000000000000000000000000000000000000 + ``` +4. ``` + PUSH 0x8000000000000000000000000000000000000000000000000000000000000000 + PUSH 0xff + SHR + --- + 0x0000000000000000000000000000000000000000000000000000000000000001 + ``` +5. ``` + PUSH 0x8000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x0100 + SHR + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +6. ``` + PUSH 0x8000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x0101 + SHR + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +7. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x00 + SHR + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +8. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x01 + SHR + --- + 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +9. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0xff + SHR + --- + 0x0000000000000000000000000000000000000000000000000000000000000001 + ``` +10. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x0100 + SHR + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +11. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x01 + SHR + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` + +### `SAR` (arithmetic shift right) + +1. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0x00 + SAR + --- + 0x0000000000000000000000000000000000000000000000000000000000000001 + ``` +2. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000001 + PUSH 0x01 + SAR + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +3. ``` + PUSH 0x8000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x01 + SAR + --- + 0x12000000000000000000000000000000000000000000000000000000000000000 + ``` +4. ``` + PUSH 0x8000000000000000000000000000000000000000000000000000000000000000 + PUSH 0xff + SAR + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +5. ``` + PUSH 0x8000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x0100 + SAR + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +6. ``` + PUSH 0x8000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x0101 + SAR + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +7. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x00 + SAR + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +8. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x01 + SAR + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +9. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0xff + SAR + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +10. ``` + PUSH 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0x0100 + SAR + --- + 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + ``` +11. ``` + PUSH 0x0000000000000000000000000000000000000000000000000000000000000000 + PUSH 0x01 + SAR + --- + 0x0000000000000000000000000000000000000000000000000000000000000000 + ``` +12. ``` + PUSH 0x4000000000000000000000000000000000000000000000000000000000000000 + PUSH 0xfe + SAR + --- + 0x0000000000000000000000000000000000000000000000000000000000000001 + ``` +13. ``` + PUSH 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + PUSH 0xf8 + SAR + --- + 0x000000000000000000000000000000000000000000000000000000000000007f + ``` + ## Implementation