Arm Community
Site
Search
User
Site
Search
User
Forums
Arm Development Studio forum
typecast arm problem
Jump...
Cancel
Locked
Locked
Replies
3 replies
Subscribers
118 subscribers
Views
3327 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
typecast arm problem
axesnetwork
over 12 years ago
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
Peter Harris
over 12 years ago
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.
Cancel
Vote up
0
Vote down
Cancel
Reply
Peter Harris
over 12 years ago
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.
Cancel
Vote up
0
Vote down
Cancel
Children
No data