min, max macros

Will be used later for things like updating `MemorySize`.
This commit is contained in:
Daniel Lubarov 2022-08-03 13:44:44 -07:00
parent 002b568a12
commit f58990160e

View File

@ -140,6 +140,11 @@
// stack: input >= c, ...
%endmacro
%macro consume_gas_const(c)
PUSH $c
CONSUME_GAS
%endmacro
// If pred is zero, yields z; otherwise, yields nz
%macro select
// stack: pred, nz, z
@ -188,3 +193,25 @@
mul
// stack: x^2
%endmacro
%macro min
// stack: x, y
DUP2
DUP2
// stack: x, y, x, y
LT
// stack: x < y, x, y
%select_bool
// stack: min
%endmacro
%macro max
// stack: x, y
DUP2
DUP2
// stack: x, y, x, y
GT
// stack: x > y, x, y
%select_bool
// stack: max
%endmacro