{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/EIPs/issues/145","repository_url":"https://api.github.com/repos/ethereum/EIPs","labels_url":"https://api.github.com/repos/ethereum/EIPs/issues/145/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/EIPs/issues/145/comments","events_url":"https://api.github.com/repos/ethereum/EIPs/issues/145/events","html_url":"https://github.com/ethereum/EIPs/issues/145","id":174725295,"number":145,"title":"EVM opcodes: bitwise shifting","user":{"login":"axic","id":20340,"avatar_url":"https://avatars.githubusercontent.com/u/20340?v=3","gravatar_id":"","url":"https://api.github.com/users/axic","html_url":"https://github.com/axic","followers_url":"https://api.github.com/users/axic/followers","following_url":"https://api.github.com/users/axic/following{/other_user}","gists_url":"https://api.github.com/users/axic/gists{/gist_id}","starred_url":"https://api.github.com/users/axic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axic/subscriptions","organizations_url":"https://api.github.com/users/axic/orgs","repos_url":"https://api.github.com/users/axic/repos","events_url":"https://api.github.com/users/axic/events{/privacy}","received_events_url":"https://api.github.com/users/axic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2016-09-02T10:08:18Z","updated_at":"2016-09-13T00:00:30Z","closed_at":null,"body":"This replaces #105.\r\n\r\n### Motivation\r\n\r\nTo provide native bitwise shifting with cost on par with other arithmetic operations.\r\n\r\n### Specification\r\n\r\nThe following new EVM opcodes are introduced:\r\n- 1) `0x1b`: `SHL` (logical left shift)\r\n- 2) `0x1c`: `SHR` (logical right shift)\r\n- 3) `0x1d`: `SAR` (arithmetic right shift)\r\n- 4) `0x1e`: `ROL` (rotate left)\r\n- 5) `0x1f`: `ROR` (rotate right)\r\n\r\nThe gast cost is set at `verylow` (3 gas) \r\n\r\nAll shift / rotate instructions take two stack elements (i.e. `value << index`), with the top element being the `index` to shift with and the next stack element is the `value`. Both `index` and `value` is considered as unsigned, with the exception of `SAR`, where `value` is signed.\r\n\r\nAll results must be mod `2^256`.\r\n\r\nFor `index` ≥ 256, the result is `0`.\r\n\r\n### Effect\r\n\r\nThis effectively reduces the gas cost and number of instructions for the above. A `SHL` and `SHR` can be implemented as `a * (2 ** b)` ( and `a / (2 ** b)` respectively. The upper gas bound for these is 35 gas.\r\n\r\n`SAR` and the rotation opcodes cost more than 35."},"comment":{"url":"https://api.github.com/repos/ethereum/EIPs/issues/comments/246532882","html_url":"https://github.com/ethereum/EIPs/issues/145#issuecomment-246532882","issue_url":"https://api.github.com/repos/ethereum/EIPs/issues/145","id":246532882,"user":{"login":"axic","id":20340,"avatar_url":"https://avatars.githubusercontent.com/u/20340?v=3","gravatar_id":"","url":"https://api.github.com/users/axic","html_url":"https://github.com/axic","followers_url":"https://api.github.com/users/axic/followers","following_url":"https://api.github.com/users/axic/following{/other_user}","gists_url":"https://api.github.com/users/axic/gists{/gist_id}","starred_url":"https://api.github.com/users/axic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axic/subscriptions","organizations_url":"https://api.github.com/users/axic/orgs","repos_url":"https://api.github.com/users/axic/repos","events_url":"https://api.github.com/users/axic/events{/privacy}","received_events_url":"https://api.github.com/users/axic/received_events","type":"User","site_admin":false},"created_at":"2016-09-13T00:00:30Z","updated_at":"2016-09-13T00:00:30Z","body":"Do we all agree:\r\n- to remove `SAR`?\r\n- that for rotations `index` is `mod 256`\r\n- and for shifts, `index ≥ 256` still means 0?"}}
{"actor":{"display_login":"axic"}}