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

SAM7.s branch to main() causes SWI. Why ?

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

Parents
  • 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

Reply
  • 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

Children