def put_byte

lawful-words@0.1.0.0 · defs.bend:24

import lawful-words@0.1.0.0/defs.bend as Defs
import Base

24# w with byte j replaced by b: (w & ~(255 << 8j)) | (b << 8j). Meant for
25# b < 256 and j < 4: a larger b spills into the next byte, and from j = 4 up
26# the word is unchanged.
27def put_byte(w: U32, +j: Nat, b: U32) -> U32:
28  U32.or(U32.and(w, U32.not(U32.shln(255, Nat.mul(8n, j)))), U32.shln(b, Nat.mul(8n, j)))

Uses (7)

Used by (28)