Skip to content

Need support for splitting an integer. #27

@j3pic

Description

@j3pic

Consider the EDID format used by HDMI monitors: https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#EDID_1.4_data_format

Part of this spec calls for an integer whose lowest 8 bits are followed by the lowest 8 bits of an unrelated integer, followed by the highest 4 bits of the first integer, then the highest 4 bits of the second integer.

Something like this:

(defbinary troll-format (:byte-order :big-endian)
    (number-of-frobs 0 :type (unsigned-byte 8))
    (unrelated-cruft 0 :type (unsigned-byte 8))
    (rest-of-number-of-frobs 0 :type (unsigned-byte 4)) ;; u mad bro?
    (rest-of-unrelated-cruft 0 :type (unsigned-byte 4)))

I've seen other formats that do things like this (but never an explanation of why someone would do
this), so perhaps there should be some way to specify that REST-OF-NUMBER-OF-FROBS is part of NUMBER-OF-FROBS (and which part it is in that case, since someone could specify a format in which the chunks are laid out in middle-endian order).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions