comp.lang.ada
 help / color / mirror / Atom feed
From: Marc Bouvette <marc.bouvette@canada.cdev.com>
To: wdwright@ccgate.hac.com
Subject: Re: help - bit twiddling anomoly
Date: 1996/05/13
Date: 1996-05-13T00:00:00+00:00	[thread overview]
Message-ID: <4n7vvo$7m4@magpie.cdev.com> (raw)
In-Reply-To: 3193C6C3.7FEC@ccgate.hac.com


David,

I'm a little concerned with the "at mod 1" you have specified to align the 16-bit 
"br" record.  I would venture a guess that the compiler is aligning the record on an 
odd byte boundary and then mixing in the "wdw" (character) variable with one-half of 
the "br" record to form a 16 bit word.  Thus you may not be assigning the result of 
the bit shift to where you think you are.

Consider the following example (for a Motorola 68K)

Address ----------------------------- Address
0x8000  |   Byte #1   |   Byte #2   | 0x8001
        -----------------------------
0x8002  |   Byte #3   |   Byte #4   | 0x8003
        -----------------------------

I would expect the alignment of the record to occupy Byte #1 and Byte #2.  However, 
if your compiler has decided to align the record on Byte #2 and Byte #3 due to 
the "at mod 1" then perhaps it has placed the "wdw" variable on Byte #4 when defined 
as a single "character".

I'm not familiar with SPARC technology, but in 68K this would make sense as "bit0" 
would be part of the high byte, potentially aligned on Byte #2.  If this is the case 
then perhaps the value of bit0 in Byte #2 never actually changes and is always left 
at 0 (presumably its initial value).

Give it a try!






  parent reply	other threads:[~1996-05-13  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 ` Theodore E. Dennison
1996-05-11  0:00 ` Robert A Duff
1996-05-13  0:00 ` Marc Bouvette [this message]
1996-05-13  0:00 ` Kirk Davis
replies disabled

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