Checked multiword right shifts #
Whole half-word digits are skipped by subtracting the half width from a physical scalar. The remaining shift is division by a power of two, performed from high digits to low digits with a remainder carry. Each intermediate is strictly below the square of the digit radix.
Main definitions #
Cslib.WordRAM.Multiword.Shift.program: variable right shift with fixed register lists.
Main results #
Cslib.WordRAM.Multiword.Shift.exec: bounded digits, exact reconstruction and a frame.Cslib.WordRAM.Multiword.Shift.exec_eighteen: the eighteen-digit bank interface.
The code may depend on the physical width through constants. Its size and runtime bounds depend only on the digit counts. Inputs and outputs are disjoint little-endian digit lists; the scalar is a separate physical word. All four reserved registers may change.
References #
One division digit. base is the radix, zero the divisor, and total the shift.
Instances For
Set up the residual power-of-two divisor and divide the remaining digits.
Instances For
Exact instruction-list size before the three-instruction initialization.
Instances For
Variable right shift from a physical scalar word. The output is padded to its fixed length.
All arithmetic, including construction of the residual power of two, is checked at width w.
The frame preserves memory and every register outside the output and reserved workspace.
Extract the outside-output register guarantee from the complete four-register frame.
A shift beyond the full digit capacity is zero. Combined with exec, this also describes
the runtime's large-shift branch, without requiring its scalar to fit the digit radix.
The MSB bank's eighteen-digit shift takes at most 79 instructions, including initialization. Every non-output register numbered at least four is preserved, including the scalar.