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

Copy Markdown View Source

EVM comparison opcodes: LT, GT, SLT, SGT, EQ, ISZERO.

Summary

Functions

Applies a comparison 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 comparison opcode to the stack (a list, top first) and returns the new stack.

ByteMnemonicOperation
0x10LT1 if a < b (unsigned), else 0
0x11GT1 if a > b (unsigned), else 0
0x12SLT1 if a < b (signed two's complement), else 0
0x13SGT1 if a > b (signed two's complement), else 0
0x14EQ1 if a == b, else 0
0x15ISZERO1 if a == 0, else 0 (unary)

The interpreter has already checked that the stack holds the opcode's inputs.

iex> EEVM.Interpreter.Instructions.Comparison.stack_op(0x10, [1, 2, 9])
[1, 9]