comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com
Subject: Re: Problem to dramatize packed-array/rep-clause difficulties
Date: 1996/03/27
Date: 1996-03-27T00:00:00+00:00	[thread overview]
Message-ID: <4jaun6$st6@news2.delphi.com> (raw)

In <4jankp$30h@ra.nrl.navy.mil> Doug Rogers gave an unaccepted-by-his-
compiler solution to a problem.  Here is an alternate for his specific
problem which at least my compiler accepts - I don't know about Dougs.

These are the nine-bit changes, similar logic handles the six bit ones.
Its elegance, of course, is in the eye of the beholder.  ;)

Assume since bits are specified in Intel order that bytes are also, ie,
that the low order bit of the second byte is in fact the highest order
bit of the first Natural9 value, rather than its lowest order bit.

--type High_Res_Data is array (Natural range 0 .. 7) of Natural9;

  type High_Res_Data is record
    a:Natural9;
    b:Natural9;
    c:Natural9;
    d:Natural9;
    e:Natural9;
    f:Natural9;
    g:Natural9;
    h:Natural9;
  end record;

  for High_Res_Data use record
    a at 0 range 0 .. 8;
    b at 1 range 1 .. 9;
    c at 2 range 2 .. 10;
    d at 3 range 3 .. 11;
    e at 4 range 4 .. 12;
    f at 5 range 5 .. 13;
    g at 6 range 6 .. 14;
    h at 7 range 7 .. 15;
  end record;
  for High_Res_Data'size use 72;

  ...

      when High =>
--      for Index in High_Res_Data'range loop
--        Put ("  Data (");
--        Put (Natural (Index), Width => 1);
--        Put (") => ");
--        Put (Natural (S.High_Res (Index)));
--        New_Line;
--      end loop;
        Put_Line("  Data (0) =>" & Natural9'image(S.High_Res.a));
        Put_Line("  Data (1) =>" & Natural9'image(S.High_Res.b));
        Put_Line("  Data (2) =>" & Natural9'image(S.High_Res.c));
        Put_Line("  Data (3) =>" & Natural9'image(S.High_Res.d));
        Put_Line("  Data (4) =>" & Natural9'image(S.High_Res.e));
        Put_Line("  Data (5) =>" & Natural9'image(S.High_Res.f));
        Put_Line("  Data (6) =>" & Natural9'image(S.High_Res.g));
        Put_Line("  Data (7) =>" & Natural9'image(S.High_Res.h));
    end case;
-----------------------------------




             reply	other threads:[~1996-03-27  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-27  0:00 tmoran [this message]
1996-03-27  0:00 ` Problem to dramatize packed-array/rep-clause difficulties Doug Rogers
1996-03-27  0:00   ` Robert Dewar
1996-03-27  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-03-28  0:00 tmoran
1996-03-28  0:00 ` Robert Dewar
1996-03-28  0:00 tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox