Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Un-aligned data access on ARM7 core

2005-12-17 by Robert Adsett

At 09:52 AM 12/17/05 +0100, Marko Panger wrote:
>Your replies are just what I was looking for. I needed a confirmation of
>my understanding and I got it. For me, is normal not to receive a
>warning in this situation because the compiler was forced by you. And
>yes, different micros will react differently. Some will issue bus error,
>some will read incorrect value and so on. My co-workers claimed up on
>the micro and compiler that this should be handled but I really can't
>imagine how if the compiler was forced.
>
>This code was ported from an 8 bit machine (with 8 bit data bus) when
>such things works regardless of "buf" alignment, because buf is accessed
>every time 8 bit, regardless of the cast.
>
>The only thing that I was surprised was my PC box where this was possible.

PCs and PC programmers tend to allow and encourage a lot of things that are 
very bad practice in the embedded world.  Arguably they are bad even in the 
PC world but the costs are low.


>My conclusion is that un-supported un-aligned accesses are not
>compiler/cpu bug but are compiler/cpu FEATURE and a skilled programmers
>should RTFM and be aware of this.


Yep, and one thing I didn't point out earlier is that your example also 
appears to depend on the sizes of both char and short which are not 
guaranteed to be specific sizes.  They often are 8 bits and 16bits 
respectively but both can be larger.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.