EEVM.Interpreter.Instructions.Bitwise (eevm v0.1.0)

Copy Markdown View Source

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

stack_op(int, list)

@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.

ByteMnemonicOperation
0x16ANDbitwise AND of a and b
0x17ORbitwise OR of a and b
0x18XORbitwise XOR of a and b
0x19NOTbitwise complement (all 256 bits flipped)
0x1ABYTEbyte at index i of x (big-endian, 0 = MSB)
0x1BSHLlogical left shift: x << shift mod 2^256
0x1CSHRlogical right shift: x >> shift
0x1DSARarithmetic right shift (sign-preserving)
0x1ECLZcount 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]