From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Does Ada support endiannes?
Date: Mon, 12 Dec 2011 11:23:40 +0200
Date: 2011-12-12T11:23:40+02:00 [thread overview]
Message-ID: <9klvdnF29pU1@mid.individual.net> (raw)
In-Reply-To: <23835087-313f-427c-b37e-4ff1bdef9d57@r6g2000yqr.googlegroups.com>
On 11-12-12 10:57 , Gerd wrote:
> Hello,
>
> a while ago, I worked at Siemens company, with a (CHILL-)compiler that
> supports endianess similar to this:
>
> litte : Integer; pragma Datalayout(Little_Endian);
> big : Integer; pragma Dtalayout(Big_Endian);
>
> little := big; -- compiler generates code for converting big endian to
> little endian
>
> if little = big -- compiler converts the variables to machines nativ
> format before testing
>
>
> Is there something similar available with Ada?
No.
> Or has someone any suggestions how to rewrite it in ada?
Assuming that the native format is big-endian, you could define a new type:
type Little_Endian_Integer is record ... end record;
and write representation specifications to lay out the components of the
type in a little-endian way. But you would then have write your own
implementations of all arithmetic operations on Little_Endian_Integer,
for example the "+" operator, including forms that mix types, for
example for Integer + Little_Endian_Integer.
In practice, it would be much easier to write only two conversion
functions, to convert to and from the non-native endianness, and call
those functions only at the start and end of a computation to load and
store the variables that use the non-native endianness.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2011-12-12 9:22 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 8:57 Does Ada support endiannes? Gerd
2011-12-12 9:23 ` Niklas Holsti [this message]
2011-12-12 11:27 ` Dmitry A. Kazakov
2011-12-12 12:44 ` Gerd
2011-12-12 19:23 ` Jeffrey Carter
2011-12-13 14:25 ` Gerd
2011-12-13 14:19 ` Gautier write-only
2011-12-14 16:16 ` Gerd
2011-12-14 18:16 ` Dmitry A. Kazakov
2011-12-14 20:16 ` Gautier write-only
2011-12-15 11:27 ` Gerd
2011-12-15 13:01 ` Simon Wright
2011-12-15 13:37 ` Dmitry A. Kazakov
2011-12-15 20:12 ` Jeffrey Carter
2011-12-12 12:46 ` Gerd
2011-12-12 13:22 ` Dmitry A. Kazakov
2011-12-12 17:07 ` Charles H. Sampson
2011-12-12 18:33 ` Dmitry A. Kazakov
2011-12-14 5:19 ` Charles H. Sampson
2011-12-14 8:56 ` Dmitry A. Kazakov
2011-12-14 9:46 ` Simon Wright
2011-12-15 9:14 ` Charles H. Sampson
2011-12-15 9:46 ` Dmitry A. Kazakov
2011-12-25 21:42 ` Charles H. Sampson
2011-12-26 10:47 ` Dmitry A. Kazakov
2011-12-27 10:38 ` Georg Bauhaus
2011-12-27 12:35 ` Dmitry A. Kazakov
2012-01-04 4:33 ` Charles H. Sampson
2012-01-04 11:56 ` Dmitry A. Kazakov
2011-12-12 13:33 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox