MCPcopy Create free account
hub / github.com/BitVM/BitVM / u4_2_nib_shift_stack

Function u4_2_nib_shift_stack

bitvm/src/u4/u4_shift_stack.rs:83–93  ·  view source on GitHub ↗

Assuming the u4 numbers X and Y are on top of the stack, calculates (16 * Y + X) >> n modulo 16

(
    stack: &mut StackTracker,
    tables: StackVariable,
    n: u32,
)

Source from the content-addressed store, hash-verified

81
82/// Assuming the u4 numbers X and Y are on top of the stack, calculates (16 * Y + X) >> n modulo 16
83pub fn u4_2_nib_shift_stack(
84 stack: &mut StackTracker,
85 tables: StackVariable,
86 n: u32,
87) -> StackVariable {
88 assert!((1..4).contains(&n));
89 u4_lshift_stack(stack, tables, 4 - n);
90 stack.op_swap();
91 u4_rshift_stack(stack, tables, n);
92 stack.op_add()
93}
94
95/// Assuming the u4 numbers X and Y are on top of the stack, calculates (16 * Y + X) >> 3 modulo 16
96pub fn u4_2_nib_shift_blake(stack: &mut StackTracker, tables: StackVariable) -> StackVariable {

Callers 1

Calls 2

u4_lshift_stackFunction · 0.85
u4_rshift_stackFunction · 0.85

Tested by 1