def pack_vals(a, b, c, d, offset=0):
    """Packs 4 byte values into a 32-bit word
    offset is subtracted from the values before storing
    """
    return (((a - offset) & 0xff)
            + (((b - offset) & 0xff) << 8)
            + (((c - offset) & 0xff) << 16)
            + (((d - offset) & 0xff) << 24))