def AcpiChecksum.byte_for

bend-osdev-acpi@0.1.1.0 · checksum.bend:23

import bend-osdev-acpi@0.1.1.0/checksum.bend as Checksum
import Base
import bend-osdev-bytes@0.1.1.0/bytes.bend as B

23# the byte that, put at offset i of o (whose byte there is ignored), makes
24# o sum to zero modulo 256
25def AcpiChecksum.byte_for(+i: Nat, +o: B.Octets) -> U32:
26  +without = U32.and(255, U32.sub(AcpiChecksum.sum(o), U32.and(255, Maybe.default(&2, U32, B.Octets.at(o, i), 0))))
27  U32.and(255, U32.sub(256, without))

Uses (8)

Used by (2)