Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PPC can't write to a misaligned address ?

303 views
Skip to first unread message

jason_edwards

unread,
Sep 25, 2000, 3:00:00 AM9/25/00
to
Hi,

I'm having a problem writing 4 byte values ( specifically floats ) to
misaligned addresses using a MVME-2700 card ( PPC604 ) , Tornado 2, VxWorks
5.4. This would not normally be a big problem, except I need to write to
pre-defined addresses on an I/O card and I can't choose to have the float
values on 4 byte boundaries.

I can write integer values OK, irrespective of whether the address is 1,2 or
4 byte aligned, but I get an alignment exception whenever I try to write a
float value to an address that isn't 4 bye aligned.

I've cut and pasted some output from my console demonstrating the problem.
In
this example I created a variable in the shell ( just to get a legitimate
address, since you don't have access to my hardware ) then I try to write a
float value to this address with various offsets. You can see that I get an
alignment exception if I try to write to an address that isn't 4 byte
aligned.


Here's the console output;

proc0-> x=0
new symbol "x" added to symbol table.
x = 0x1a18420: value = 0 = 0x0

** Write to 4 byte aligned address - No problem**
proc0-> vp = 0x1a18420
new symbol "vp" added to symbol table.
vp = 0x1a183f0: value = 27362336 = 0x1a18420 = x
proc0-> *vp=(float)1.5
x = 0x1a18420: value = 1.5

** Write to misaligned address - Alignment exception occurs **

proc0-> vp = 0x1a18421
vp = 0x1a183f0: value = 27362337 = 0x1a18421 = x + 0x1
proc0-> *vp=(float)1.5

alignment
Exception current instruction address: 0x001ebf44
Machine Status Register: 0x0000b030
Data Access Register: 0x01a18421
Condition Register: 0x44400040
Data storage interrupt Register: 0x00002803

1c9b8c vxTaskEntry +60 : shell ()
18da74 shell +18c: 18daa0 ()
18dcc4 shell +3dc: execute ()
18de48 execute +d8 : yyparse ()
1ef10c yyparse +1364: 1ebe3c ()
shell restarted.


Windriver claim the PowerPC memory controller and instruction set are not
intelligent enough to write long integers to misaligned addresses, and will
usually cause a fault. However, for certain configurations, it will cause
bad data instead of a fault.

Does this mean it is *** IMPOSSIBLE *** to atomically write a float value to
a misaligned address ????

Thanks

--

Jason Edwards

Technical Consultant
Keyspan Technology Ltd

Web : www.keyspan.co.uk
E-Mail : ja...@keyspan-nospam.co.uk

Remove -nospam to reply to me personally

Marcelo & Keyly Mourier

unread,
Sep 25, 2000, 3:00:00 AM9/25/00
to
Different processors in the PPC family handle misaligned operands differently.
For example, the Motorola PPC603 is able to access misaligned integer operands
fine, but the IBM PPC403 crashes with a data access exception. I'm not sure if
the 603 crashes when you use floating point operands, as you mention the 604
does. A simple workaround to this problem could be to move the floating point
operand into one of the general purpose integer registers, and then store it as
an integer...

jason_edwards

unread,
Sep 26, 2000, 3:00:00 AM9/26/00
to
Thanks Marcello,

I originally intended to resolve the problem exactly as you recommend - By
writing the float value as a long integer. I know this solution works, but
unfortunately WindRiver say that this is a bug and shouldn't actually work
at all ! According to them it is not possible to * RELIABLY* write either
a float or long integer value to a misaligned address.

Jason

Marcelo & Keyly Mourier wrote in message
<39CF980F...@earthlink.com>...


>Different processors in the PPC family handle misaligned operands
differently.
>For example, the Motorola PPC603 is able to access misaligned integer
operands
>fine, but the IBM PPC403 crashes with a data access exception. I'm not sure
if
>the 603 crashes when you use floating point operands, as you mention the
604
>does. A simple workaround to this problem could be to move the floating
point
>operand into one of the general purpose integer registers, and then store
it as
>an integer...
>
>"Jason Edwards" wrote:


<snip>

>> I can write integer values OK, irrespective of whether the address is 1,2
or
>> 4 byte aligned, but I get an alignment exception whenever I try to write
a
>> float value to an address that isn't 4 bye aligned.


<snipped>

Joe Durusau

unread,
Sep 26, 2000, 3:00:00 AM9/26/00
to
When the compiler is set up to handle misaligned addresses, it breaks
up the data into characters(bytes) and writes them that way. Since this
encounters
a horriffic performance penalty, I suggest that you use a function to do
the misaligned
write when you need to do so, rather than using the compiler flag.
Since most of the
more modern processors are not capable of directly handling misaligned
addresses, you
might talk to the I/O board vendor and see if there is a way to
re-arrange addressing
on it.

Speaking only for myself,

Joe Durusau

0 new messages