def AcpiChecksum.byte_for
import bend-osdev-acpi@0.1.1.0/checksum.bend as Checksumimport 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))