EVM bitwise opcodes: AND, OR, XOR, NOT, BYTE, SHL, SHR, SAR, CLZ.
Summary
Functions
Applies a bitwise opcode to the stack (a list, top first) and returns the new stack.
Functions
@spec stack_op(non_neg_integer(), [non_neg_integer()]) :: [non_neg_integer()]
Applies a bitwise opcode to the stack (a list, top first) and returns the new stack.
| Byte | Mnemonic | Operation |
|---|---|---|
| 0x16 | AND | bitwise AND of a and b |
| 0x17 | OR | bitwise OR of a and b |
| 0x18 | XOR | bitwise XOR of a and b |
| 0x19 | NOT | bitwise complement (all 256 bits flipped) |
| 0x1A | BYTE | byte at index i of x (big-endian, 0 = MSB) |
| 0x1B | SHL | logical left shift: x << shift mod 2^256 |
| 0x1C | SHR | logical right shift: x >> shift |
| 0x1D | SAR | arithmetic right shift (sign-preserving) |
| 0x1E | CLZ | count of leading zero bits in x (256 if x = 0) |
The interpreter has already checked that the stack holds the opcode's inputs.
iex> EEVM.Interpreter.Instructions.Bitwise.stack_op(0x1B, [4, 1])
[16]