def t32.update.msb

bend-osdev-crc@0.1.0.0 · table.bend:60

import bend-osdev-crc@0.1.0.0/table.bend as Table
import Base
import bend-osdev-crc@0.1.0.0/crc.bend as C

60# most significant bit first: a table for widths of 8 and up; below 8 the
61# input goes in a bit at a time, so the bitwise engine serves
62def t32.update.msb(small: Bool, +width: Nat, +poly: U32, c: U32, xs: List<&2, U32>) -> U32:
63  match small:
64    case True{}:
65      C.s32.raw(xs, poly, Nat.sub(width, 1n), U32.sub(U32.shln(1, width), 1), c)
66    case False{}:
67      +shift = Nat.sub(width, 8n)
68      +topbit = U32.shln(1, Nat.sub(width, 1n))
69      +mask = U32.sub(U32.shln(1, width), 1)
70      t32.snd(t32.n.raw(xs, shift, mask, (t32.fill.n(256n, [0 : U32*256n], poly, shift, topbit, mask, 0), c)))

Uses (13)

Used by (1)