Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Endian-prob...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 5605 of 5800
Post > Topic >>

Re: Endian-problem/bug with system.bit_ops (gnat3.15)...

by Niklas Holsti <niklas.holsti@[EMAIL PROTECTED] > Mar 15, 2008 at 02:22 PM

Erik Baigar wrote:
> Dear Ada users,
> 
> in ****ting 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 re****t this 
problem and your solution?

I think that your program could be made more ****table 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
       .      @[EMAIL PROTECTED]
       .
 




 5 Posts in Topic:
Endian-problem/bug with system.bit_ops (gnat3.15)...
Erik Baigar <erik@[EMA  2008-03-15 08:58:12 
Re: Endian-problem/bug with system.bit_ops (gnat3.15)...
Niklas Holsti <niklas.  2008-03-15 14:22:36 
Re: Endian-problem/bug with system.bit_ops (gnat3.15)...
Erik Baigar <erik@[EMA  2008-03-15 19:53:00 
Re: Endian-problem/bug with system.bit_ops (gnat3.15)...
Niklas Holsti <niklas.  2008-03-15 21:26:22 
Re: Endian-problem/bug with system.bit_ops (gnat3.15)...
Erik Baigar <erik@[EMA  2008-03-15 20:45:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 19:01:30 CDT 2008.