def append.words

lawful-bytes@0.1.1.0 · fast.bend:111

import lawful-bytes@0.1.1.0/fast.bend as Fast
import Base

111# n words to dst from word di on, taken from src's bytes at a shift of sh
112# bits: lo is src word si, r holds word si + 1.
113def append.words(n: Nat, r: Array<U32> & U32, +lo: U32, dst: Array<U32>, +si: U32, +di: U32, +sh: Nat) -> Array<U32> & Array<U32>:
114  match n:
115    case 0n:
116      (src, w) = r
117      (dst, src)
118    case 1n+k:
119      (src, +hi) = r
120      append.words(k, Array.get(U32, src, (si + 2 : U32)), hi, Array.set(U32, dst, di, (U32.shrn(lo, sh) .|. U32.shln(hi, Nat.sub(32n, sh)) : U32)), (si + 1 : U32), (di + 1 : U32), sh)

Uses (12)

Used by (3)