[M3devel] Modula-3 bitfields

Mika Nystrom mika at async.caltech.edu
Fri Aug 24 21:28:59 CEST 2012


=?utf-8?Q?Dragi=C5=A1a_Duri=C4=87?= writes:
...
>to me :). Like, I really started to like how high-level programs look =
>like, esp ones doing various low-level stuff :). I like to think =
>abstract, to write high-level, readable programs. Ones I don't have =
>problems maintaining for prolonged time intervals.
>
>  I don't need anything funny. I just need a way to represent, in a =
>readable manner, standard communication data structures. So I can =
>continue with my trade without C,
>
>>=20
>> Here's an example.  A PCI Express DLLP is 32 bits of payload followed =
>by
>> a 16-bit CRC.  Should I be able to write this as follows:
>>=20
>> DLLP =3D RECORD
>>  payload : BITS 32 FOR [0..16_ffffffff];
>>  crc     : BITS 16 FOR [0..16_ffff];
>> END;
>>=20
>> What then is the layout of=20
>>=20
>> ARRAY [0..1] OF DLLP;
>>=20
>
>Maybe you meant to write: ARRAY [0..1] OF BITS 48 FOR DLLP; ?

And what does that mean, exactly?  No gaps allowed?  What does it
mean, in particular, on a little-endian machine?

What about ARRAY [0..1] OF BITS 31 FOR [0..16_8fffffff] ?

What I am proposing isn't particularly difficult, it's not unportable,
either.  And much more powerful than any sets of pragmas.  Not tied to
your one architecture.

     Mika



More information about the M3devel mailing list