comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Endian-problem/bug with system.bit_ops (gnat3.15)...
Date: Sat, 15 Mar 2008 14:22:36 +0200
Date: 2008-03-15T14:22:36+02:00	[thread overview]
Message-ID: <47dbbacc$0$23854$4f793bc4@news.tdc.fi> (raw)
In-Reply-To: <47DB8194.62FE76B0@baigar.de>

Erik Baigar wrote:
> Dear Ada users,
> 
> in porting an application from Meridian's Ada83 to gnat3.15 I
> encountered some issues with the system.bit_ops...
>  
>   Bit_And ( MEMORY (OPERAND_ADDRESS)'Address,18, ACCUMULATOR'Address,18,
>             ACCUMULATOR'Address);
> 
> ... This code works well
> on the Intel (little endian) platform but fails on SPARC (big endian).
> It required some investigation to locate the problem, but replacing 
> the length 18 by 32 (all are integers here), i.e. using
> 
>   Bit_And ( MEMORY (OPERAND_ADDRESS)'Address,32, ACCUMULATOR'Address,32,
>             ACCUMULATOR'Address);
> 
> solved the problem and the code now runs on little and big endian 
> systems.

Anything that accesses a variable using Variable'Address but then 
operates only on a part of the variable (eg. 18 bits of a 32-bit 
variable) sounds very likely to have problems with endianness, if 
the storage unit is smaller than the size of the variable.

Did you have a question to ask, or did you just want to report this 
problem and your solution?

I think that your program could be made more portable by avoiding 
'Address (and, of course, System.Bit_Ops) and using instead modular 
types (not available in Ada83) and their predefined bitwise "and" 
and "or" operations.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  reply	other threads:[~2008-03-15 12:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-15  7:58 Endian-problem/bug with system.bit_ops (gnat3.15) Erik Baigar
2008-03-15 12:22 ` Niklas Holsti [this message]
2008-03-15 18:53   ` Erik Baigar
2008-03-15 19:26     ` Niklas Holsti
2008-03-15 19:45       ` Erik Baigar
replies disabled

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