Yahoo Groups archive

Lpc2000

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

Message

Re: [lpc2000] Re: For C Experts

2006-03-30 by Geoffrey Wang

I believe he's saying that the compiler may/may not be intelligent enough to follow the logic and perform
byte-wise transfers.  I had the same issue with the Green Hills ARM toolset in trying to force a 
data abort for exception handling testing.  Of course, I've never seen this documented.

The GHS toolset used byte-wise transfers for

*((volatile int *) 0x00000001) = 0x12345678;

and had to obfuscate it to make a data abort

    volatile dword i;

   i = 1;
    *((unsigned int *) i) = 0x12345678;


Geoffrey
  When you say "I believe that the compiler has enough information to 
  use byte aligned transfers", are you refering to the line:

  x[4] = *ip

  If so, why do you expect byte transfers? You're copying from one 
  integer sized object to another. What happened before this line is 
  irrelevant (in particular the fact that you've forced the "ip" 
  pointer to have a badly alligned value).

  Or am I misunderstanding what you're asking?

  Brendan

  --- In lpc2000@yahoogroups.com, "dsidlauskas1" <dsidlauskas@...> 
  wrote:
  >
  > Consider the following code:
  > 
  > ============================
  > char buf[]={1,2,3,4,5,6,7,8};
  > int *ip, x[4];
  > 
  > for (i=0; i<4; i++)
  >     {
  >     ip = (int *)&buf[i];
  >     x[4]  = *ip;
  >     }
  > =============================
  > The Keil compiler compiles this without warning, but does not 
  produce
  > the expected (for me) result in x. The problem is that Keil uses the
  > LDR instruction to effect the transfer and this is valid only on 4
  > byte boundaries.
  > 
  > GCC compiles but does give a non-aligned access warning.
  > 
  > I believe that the compiler has enough information to use byte 
  aligned
  > transfers, and should, or at least give a warning.
  > 
  > Anybody want to weigh in on this one.
  > 
  > Thanks in advance for your comments.
  > 
  > Dave Sidlauskas
  >






------------------------------------------------------------------------------
  YAHOO! GROUPS LINKS 

    a..  Visit your group "lpc2000" on the web.
      
    b..  To unsubscribe from this group, send an email to:
     lpc2000-unsubscribe@yahoogroups.com
      
    c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


------------------------------------------------------------------------------



[Non-text portions of this message have been removed]

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.