comp.lang.ada
 help / color / mirror / Atom feed
From: "Theodore E. Dennison" <dennison@escmail.orl.mmc.com>
Subject: Re: help - bit twiddling anomoly
Date: 1996/05/11
Date: 1996-05-11T00:00:00+00:00	[thread overview]
Message-ID: <3195036A.2781E494@escmail.orl.mmc.com> (raw)
In-Reply-To: 3193C6C3.7FEC@ccgate.hac.com


Dave Wright wrote:
> 
> Any ideas why the following code behaves strangely (other than the
> fact that its SUN SPARCworks Ada 2.1.1 running on a SPARC5 with
> Solaris 2.4)?  The only difference between the working version and the
> broken version is 8 bits of storage (string(1..2) versus character) in
> the unused object wdw.
...
> with unchecked_conversion;
> with v_i_bits;
...
> brec.bit1 := inttobit(v_i_bits.bit_sll(int,(integer'size-onebit'size)));

Since you are using a routine from the VADS internals (That's what
the "v_i" stands for), perhaps you should be asking this question to
the Rational technical support folks at
   mailto:support@rational.com

Now if you are just looking for ideas, I'm guessing that you are having
a byte-ordering problem. If the LSByte for your machine were to be
somewhere other than the lowest address in the integer, then the 
unchecked conversion from integer to a one-byte type will put the
LSByte somewhere off in never-never land.

I'm also finding it curious that you are trying to declare a one bit
integer. Ada 83 Integers weren't really meant to do that. That's the
reason Boolean'size is 1. What I'd typically do is declare a packed
array type of booleans. "AND" and "OR" work in bitwise fashion
automaticly on such arrays. You still have endian issues to deal with,
though (plus now you have to worry about how your compiler chose to
order the bits).

I'm sure you had good reasons for doing this, but it seems quite
awkward in your little example.

-- 
T.E.D.          
                |  Work - mailto:dennison@escmail.orl.mmc.com  |
                |  Home - mailto:dennison@iag.net              |
                |  URL  - http://www.iag.net/~dennison         |




  parent reply	other threads:[~1996-05-11  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-10  0:00 help - bit twiddling anomoly Dave Wright
1996-05-11  0:00 ` Robert A Duff
1996-05-11  0:00 ` Theodore E. Dennison [this message]
1996-05-13  0:00 ` Kirk Davis
1996-05-13  0:00 ` Marc Bouvette
replies disabled

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