2 > My only problem is with DEF-BITFIELD. All other BINARY-TYPES
3 > features are intuitive and easy to use.
5 Hi, you are right that DEF-BITFIELD is poorly documented. I think
6 that's because it's a bit complex and I'm not quite confident it is
7 the way it should be. Anyways, here are a couple of examples:
9 (define-bitfield r-info (u32)
22 ((:numeric r-sym 24 8))))
24 This declares R-INFO to be an unsigned 32-bit number, divided into two
25 fields. The first field resides in bits 0-7, and is one of the values
26 r-386-xx. The second field is a numeric value that resides in bits
27 8-23. So this type R-INFO may for example have symbolic value
28 (r-386-pc32 (r-sym . 1)), which translates to a numeric value of
29 (logior 2 1<<8)) = 258.
33 (define-bitfield p-flags (u8)
39 Here P-FLAGS has just one bit-field, where bit 0 is named PF-X, bit 1
40 is named PF-W etc. So the value (PF-X PF-R) maps to 5.
42 As you may see by now, DEF-BITFIELD divides a numeric base-type
43 (typically an unsigned integer) into a number of fields, where each
44 field is one of :BITS for bitmaps, :ENUM for an enumerated field
45 (takes an optional :BYTE <bytespec>), and finally :NUMERIC <byte-size>
46 <byte-pos> for a subfield that is a number.