OK, I'll try this .....

> ----------
> From:         Tucker Taft
> Reply To:     Tucker Taft
> Sent:         Friday, October 16, 1998 12:01
> To:   [log in to unmask]
> Subject:      Re: Use of attribute 'Bit_Order
>
> I would not rely on specifying the bit_order.  On the other hand,
> the value of the Default_Bit_Order constant can be useful in
> a record representation clause to control the bit positions you use,
> when combined with tricks using multiplication and Boolean'Pos().
> This is of course left as an exercise to the reader...
> -Tucker Taft
>
        ----------------

        How is this example?

with System ;
use System ;
procedure example is

-- What Tucker is alluding to is ....
--

   type Byte is mod 2 **  8;
   type Word is mod 2 ** 16;

   type Big_Endian is record
      A : Byte;
      B : Word;
      C : Byte;
   end record;

--    for Big_Endian use record
--       A at 0 range  0 ..  7;
--       B at 0 range  8 .. 23;
--       C at 0 range 24 .. 31;
--    end record;

   --  for Big_Endian'Bit_Order use System.High_Order_First;
   -- Not always supported !!!!

   -- Instead use :

   -- This is either 0 or 1 /  False or True
   Mult : constant Natural :=
     Boolean'Pos ( System.Default_Bit_Order = System.High_Order_First ) ;

   A_Low  : constant Natural :=  (Mult * 24) + 0 ;    -- 0  or 24
   A_High : constant Natural :=  (Mult * 24) + 7 ;    -- 7 or  31

   B_Low  : constant Natural :=   8 ;
   B_High : constant Natural :=  23 ;

   C_Low  : constant Natural :=  Natural ( (Mult * (-24)) + 24 ) ;
   -- 24 or 0
   C_High : constant Natural :=  Natural ( (Mult * (-24)) + 31 ) ;
   -- 31 or 7

   for Big_Endian use record
      A at 0 range  A_Low  .. A_High ;    -- 0..7   or   24..31
      B at 0 range  B_Low  .. B_High ;   -- 8..23        either way
      C at 0 range  C_Low  .. C_High ;   -- 24..31 or   0..7
   end record;

--
--
-- How's that ??? Who says you can't be clever in Ada ?
--
--


begin
   null ;

end Example;

        ---//---
"The difference between hardware and software is that the more you play with
hardware, the more likely you are to break it, but the more you play with
software the more likely you are to FIX it."
---//---
Bill Dale
LMMS
mailto:[log in to unmask]
mailto:[log in to unmask]