comp.lang.ada
 help / color / mirror / Atom feed
From: Rick Stikkers <rstikkers@telis.org>
Subject: Re: Minimum Record Size?  LONG
Date: Sat, 26 Apr 2003 18:57:26 -0700
Date: 2003-04-26T18:57:26-07:00	[thread overview]
Message-ID: <3EAB3906.7060402@telis.org> (raw)
In-Reply-To: UVlqa.620033$3D1.340565@sccrnsc01



Steve wrote:

>Here's an approach taking advantage of using "Slices" of arrays (tested
>w/Gnat3.15p-nt):
>
>  
>
If you're not worried about machine cross compatibility, the other 
option would be to just give in to the endianness of the machine and 
swap everything so that the endianness is fully preserved.  The 
following code segment gives the desired results.

with TEXT_IO;
procedure comp is

type six_bits is range 0..2**6-1;
for six_bits'SIZE use 6;
type four_sixes is record
  six_bits_0 : six_bits;
  six_bits_1 : six_bits;
  six_bits_2 : six_bits;
  six_bits_3 : six_bits;
end record;
for four_sixes use record
  six_bits_0 at 0 range 18..23;
  six_bits_1 at 0 range 12..17;
  six_bits_2 at 0 range 6..11;
  six_bits_3 at 0 range 0..5;
end record;
for four_sixes'SIZE use 24;

type eight_bits is range 0..2**8-1;
for eight_bits'SIZE use 8;
type three_eights is record
  eight_bits_0 : eight_bits;
  eight_bits_1 : eight_bits;
  eight_bits_2 : eight_bits;
end record;
for three_eights use record
  eight_bits_0 at 2 range 0..7;
  eight_bits_1 at 1 range 0..7;
  eight_bits_2 at 0 range 0..7;
end record;
for three_eights'SIZE use 24;

six_var : four_sixes;
eight_var : three_eights;
for eight_var use at six_var'ADDRESS;

begin
  six_var.six_bits_0 := 28;
  six_var.six_bits_1 := 55;
  six_var.six_bits_2 := 25;
  six_var.six_bits_3 := 50;
  text_io.put_line(eight_bits'IMAGE(eight_var.eight_bits_0)&"  "&
                          eight_bits'IMAGE(eight_var.eight_bits_1)&"   "&
                          eight_bits'IMAGE(eight_var.eight_bits_2));
end;




  reply	other threads:[~2003-04-27  1:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-25 16:33 Minimum Record Size? LONG Dr Nancy's Sweetie
2003-04-25 17:35 ` Stephen Leake
2003-04-25 17:36 ` Mark Johnson
2003-04-25 21:54   ` tmoran
2003-04-25 18:51 ` David C. Hoos
2003-04-25 21:51   ` tmoran
2003-04-26  3:00     ` David C. Hoos
2003-04-26  2:12 ` Steve
2003-04-27  1:57   ` Rick Stikkers [this message]
2003-04-27 12:06   ` David C. Hoos
2003-04-27 14:17     ` Steve
2003-04-27 20:25       ` David C. Hoos
2003-04-28  5:04         ` Steve
replies disabled

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