Hello.
In my SAM7.s startup file for AT91SAM7X256, the following instructions are executed:
. . . ; Enter the C code IMPORT __main LDR R0, =__main BX R0 . . . Disassembled as follows: 0x0010011C E24DAB01 SUB R10,R13,#0x00000400 0x00100120 E59F0024 LDR R0,[PC,#0x0024] 0x00100124 E12FFF10 BX R0 0x00100128 FFFFFD00 (???) 0x0010012C A5000401 STRGE R0,[R0,#-0x0401] 0x00100130 FFFFFF00 (???)
This BX instruction should cause my main() to be executed next. Instead, the PC executes/enters the SWI_Handler immediately after the BX instruction. Is there a fundamental issue I have overseen ? I appreciate your answers/comments to this issue.
Regards Terje Bøhler
Note that __main is the name of a startup function in the CRTL.
Your main() has the external symbol name _main - i.e. only one underscore.
You might have configured the memory regions wrong, so the CRTL startup code explodes when trying to initialize global variables and zero-initialize all memory. Or maybe the stack got placed where you don't have any RAM.
Step into, or step over? What gets loaded into R0, and what does the code there look like?
The common reason to encounter SWI or BKPT is to use printf/putc/puts etc and not having a suitable hosting environment set up.
Thank you Per for your answer! I'm new to ARM and KEIL so excuse me for my silly questions. The code is running in the simulator. Q1: You say " ...in the CRTL". What does "the CRTL" mean ? Q2: You say "You might have configured the memory regions wrong". I assume you are referring to the IROM1 and IRAM1 settings done in the "TargetOption Target"? (which is IROM1:100.000 (size=0x40.000) IRAM:0x200.000 (size:0x10.000), generated automatically) Regards Terje
C Run-Time Library