typecast arm problem

Note: This was originally posted on 29th July 2009 at http://forums.arm.com

Hi


I use eclipse+yagarto+the exemple getting-started-project-1.3-at91sam7x-ek or RTOS "ARM7_AT91SAM7X256_Eclipse". I have a problem when I do this
char var1[2];
int short var2 = 0x1234;

*(int short*)var1 = var2

When I do the typecast the arm stop working if the address is odd. Can you tell me why the arm his not able to do that and how I can solve my problem, because with the Rabbit I was able to do that. I know I can use memcpy, but with this cast I save some CPU time.
Parents
  • Note: This was originally posted on 30th July 2009 at http://forums.arm.com

    I should have mentioned that the memcpy route is often as fast as the aliased pointer route if the compiler has been told it is OK to generate unaligned accesses.

    If you are on a CPU with unaligned access support enabled "memcpy" of a small variable is often converted to a single unaligned load - compilers are very good at optimizing small memcpy accesses because they are so common in compliant C code.
Reply
  • Note: This was originally posted on 30th July 2009 at http://forums.arm.com

    I should have mentioned that the memcpy route is often as fast as the aliased pointer route if the compiler has been told it is OK to generate unaligned accesses.

    If you are on a CPU with unaligned access support enabled "memcpy" of a small variable is often converted to a single unaligned load - compilers are very good at optimizing small memcpy accesses because they are so common in compliant C code.
Children
No data
More questions in this forum