comp.lang.ada
 help / color / mirror / Atom feed
* Re: Problem to dramatize packed-array/rep-clause difficulties
@ 1996-03-27  0:00 tmoran
  1996-03-27  0:00 ` Doug Rogers
  1996-03-27  0:00 ` Robert Dewar
  0 siblings, 2 replies; 7+ messages in thread
From: tmoran @ 1996-03-27  0:00 UTC (permalink / 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;
-----------------------------------




^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Problem to dramatize packed-array/rep-clause difficulties
@ 1996-03-28  0:00 tmoran
  1996-03-28  0:00 ` Robert Dewar
  0 siblings, 1 reply; 7+ messages in thread
From: tmoran @ 1996-03-28  0:00 UTC (permalink / raw)


>Well what you are really talking about here is a repeated pattern of
>nine byte containing eight fields, so clearly the best approach ...
>if you have such a strange structure (it is one for which I have
  Of course an array of n bit fields will always have the packing
pattern repeat after Least Common Multiple(n,8) bits, and thus
can be viewed as an array of LCM(n,8)/8 -byte records, each containing
LCM(n,8)/n fields.  If access to the J-th of a packed array of n-bit
items is most efficiently implemented on a particular machine by using
a case statement on the J/(LCM(n,8)/n)-th group, then by definition a
'smart' compiler for that machine does it that way.




^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Problem to dramatize packed-array/rep-clause difficulties
@ 1996-03-28  0:00 tmoran
  0 siblings, 0 replies; 7+ messages in thread
From: tmoran @ 1996-03-28  0:00 UTC (permalink / raw)


In <dewar.828029845@schonberg> Robert Dewar said:
>It is *extremely* unlikely that any Ada compiler that *did*
>implement jamming of 9-bit packed arrays would to it this way.
  Frankly, I was surprised to hear you say that the LCM method would be
the most efficient on modern CPUs, but you're the compiler writer.  If
ACT doesn't find it worthwhile to support 9-bit packed arrays in any
way, least of all the LCM way, that's certainly their business decision
to make.  The originator of this thread might, or might not, be unhappy
if all compilers supported pragma pack, but in suboptimal ways.




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1996-03-28  0:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-27  0:00 Problem to dramatize packed-array/rep-clause difficulties tmoran
1996-03-27  0:00 ` 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

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