Calculates the bitwise AND of top 2 u4 values using XOR tables Uses the formula (a and b) = ((a + b) - a XOR b) >> 1
(
stack: &mut StackTracker,
lookup_table: StackVariable,
logic_table: StackVariable,
shift_table: StackVariable,
)
| 97 | /// Calculates the bitwise AND of top 2 u4 values using XOR tables |
| 98 | /// Uses the formula (a and b) = ((a + b) - a XOR b) >> 1 |
| 99 | pub fn u4_and_with_xor_stack( |
| 100 | stack: &mut StackTracker, |
| 101 | lookup_table: StackVariable, |
| 102 | logic_table: StackVariable, |
| 103 | shift_table: StackVariable, |
| 104 | ) -> StackVariable { |
| 105 | stack.op_2dup(); |
| 106 | u4_logic_with_table_stack(stack, lookup_table, logic_table); |
| 107 | stack.op_sub(); |
| 108 | stack.op_add(); |
| 109 | u4_rshift_stack(stack, shift_table, 1) |
| 110 | } |
| 111 | |
| 112 | #[cfg(test)] |
| 113 | mod tests { |