Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
Branching to main form assembly error
Jump...
Cancel
Locked
Locked
Replies
3 replies
Subscribers
118 subscribers
Views
3691 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
Branching to main form assembly error
sasa pavlovic
over 12 years ago
Note: This was originally posted on 25th August 2012 at
http://forums.arm.com
Hey guys, do you know why a simple branch to main from the reset handler causes an hard fault? Heres an example where I try to branch to main via the reset hander in the startup file provided by Keil and this causes an
hard fault. Any cue?
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT __main
LDR R0, =__main
BX R0
ENDP
sasa pavlovic
over 12 years ago
Note: This was originally posted on 26th August 2012 at
http://forums.arm.com
I found it, I don't know why the startup file Keilprovides load the register r0 with the address of the label
__
mainbut it certainly doesn't work for me. Instead, I load this register with the label main without the two
underscores and it work perfectly.
IMPORT main
LDR R0, =main
BLX R0
ENDP
Cancel
Vote up
0
Vote down
Cancel
Martin Weidmann
over 12 years ago
Note: This was originally posted on 28th August 2012 at
http://forums.arm.com
Your solution could cause you other problems.
The __main label is ARM's scatter loading + C library init code, which itself calls main(). So by calling main() you are by-passing the C library initialization. This may be ok, but could lead to interesting problems. For example, global variables probably won't have their initial values set.
I don't know the Keil tools to know why it didn't work before. Have you tried the dedicated Keil forums?
Cancel
Vote up
0
Vote down
Cancel
Joseph Yiu
over 12 years ago
Cancel
Vote up
0
Vote down
Cancel