Arranges (zips) the given numbers (locations given by the parameters bases) each consisting of nibble_count u4's so each group of nibbles can be proccessed disceretly Does not preserve order as it's used with commutative operations Assuming x_i denoting the i-th part of the x-th number and bases have two numbers a and b (a < b): Input: ... (a elements) a_0 a_1 a_2 a_3 ... (b - a - 1 elements) b_0
(
nibble_count: u32,
stack: &mut StackTracker,
to_copy: Vec<StackVariable>,
mut to_move: Vec<&mut StackVariable>,
constants: Vec<u32>,
)
| 57 | /// Input: ... (a elements) a_0 a_1 a_2 a_3 ... (b - a - 1 elements) b_0 b_1 b_2 b_3 |
| 58 | /// Output: b_0 a_0 b_1 a_1 b_2 a_2 b_3 a_3 ... (b elements and the rest of stack) |
| 59 | pub fn u4_arrange_nibbles_stack( |
| 60 | nibble_count: u32, |
| 61 | stack: &mut StackTracker, |
| 62 | to_copy: Vec<StackVariable>, |
| 63 | mut to_move: Vec<&mut StackVariable>, |
| 64 | constants: Vec<u32>, |
| 65 | ) { |
| 66 | let mut constant_parts: Vec<Vec<u32>> = Vec::new(); |
| 67 | |
| 68 | for n in constants { |
| 69 | let parts = (0..8).rev().map(|i| (n >> (i * 4)) & 0xF).collect(); |
| 70 | constant_parts.push(parts); |
| 71 | } |
| 72 | |
| 73 | for i in 0..nibble_count { |
| 74 | for var in to_copy.iter() { |
| 75 | stack.copy_var_sub_n(*var, i); |
| 76 | } |
| 77 | |
| 78 | for var in to_move.iter_mut() { |
| 79 | stack.move_var_sub_n(var, 0); |
| 80 | } |
| 81 | |
| 82 | for parts in constant_parts.iter() { |
| 83 | stack.number(parts[i as usize]); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /// Addition of numbers consisting of nibble_count u4's in the parameter bases locations |
| 89 | /// The overflowing bit (if exists) is omitted |