-
Notifications
You must be signed in to change notification settings - Fork 0
/
eip-145.md
23 lines (12 loc) · 2.18 KB
/
eip-145.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Summary
EIP-145 is a proposal for introducing native bitwise shifting instructions in the Ethereum Virtual Machine (EVM). The EVM currently lacks bitwise shifting operators, which are commonly used in programming languages for efficient manipulation of binary data. While shift operations can be implemented using arithmetic operators, this approach is more costly and requires more processing time from the host.
The proposal introduces three new instructions: SHL (shift left), SHR (logical shift right), and SAR (arithmetic shift right). The SHL instruction pops two values from the stack, the first being the number of bits to shift and the second being the value to shift. It then pushes the result of the shift operation onto the stack. The SHR instruction works similarly, but shifts the bits to the right with zero fill. The SAR instruction shifts the bits to the right with sign extension, meaning that the most significant bit is replicated to preserve the sign of the value.
The introduction of these instructions is motivated by the need for more efficient processing of bitwise operations in the EVM. Implementing shift operations using arithmetic operators currently costs 35 gas, while the proposed instructions only cost 3 gas. This makes them more cost-effective for contracts that require frequent bitwise operations.
The proposal also includes test cases and implementation details for the new instructions. It is important to note that the instructions are designed to be backwards compatible with existing contracts, meaning that contracts written before the introduction of the instructions will still function properly.
Overall, the EIP-145 proposal aims to improve the efficiency and cost-effectiveness of bitwise operations in the EVM by introducing native bitwise shifting instructions.
## Videos
- [Example Video Title](https://www.youtube.com/watch?v=TDGq4aeevgY)
## Projects
- [Example Project Name](https://xxxx.xxx/xxxxx) Project Description (one sentence) ![this is an img's alt for the project logo](https://xxxx.xxx/project-logo.xxx)
## Further Reading
- [Example Article Title](https://xxxx.xxx/xxxxx) ![this is an img's alt for the article cover](https://xxxx.xxx/article-cover.xxx)