ARM Technical Support Knowledge Articles

RESET VECTOR DOES NOT JUMP TO C CODE

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I have noticed that the Reset vector jumps to some assembler code, yet my project is entirely written in C. What is this assembler code? Is it junk?

ANSWER

The reset vector jumps to the startup code (which initializes the stack pointer among other things) which is written in assembler. The startup code calls the main function. If you step through this code in dScope, you should see that eventually your main function is called.

The startup code may be found in the file LIBSTARTUP.A51 in your C51 installation. Also, if you have some global or other static variables that are initialized when declared, then the code in the file LIBINIT.A51 will be called before the main function to initialize these variables. These files are included automatically when using C.

If you look at the address that the reset vector jumps to, you should see that it matches the start address of the ?C_C51STARTUP segment in the .m51 file. For example, below the start address is 0737H:

TYPE    BASE      LENGTH    RELOCATION   SEGMENT NAME
-----------------------------------------------------

* * * * * * *   D A T A   M E M O R Y   * * * * * * *
REG     0000H     0008H     ABSOLUTE     "REG BANK 0"
DATA    0008H     0015H     UNIT         _DATA_GROUP_
        001DH     0003H                  *** GAP ***
BIT     0020H.0   0001H.1   UNIT         _BIT_GROUP_
        0021H.1   0000H.7                *** GAP ***
IDATA   0022H     0001H     UNIT         ?STACK

* * * * * * *   C O D E   M E M O R Y   * * * * * * *
CODE    0000H     0003H     ABSOLUTE
        0003H     02FDH                  *** GAP ***
CODE    0300H     0355H     UNIT         ?PR?PRINTF?PRINTF
CODE    0655H     008EH     UNIT         ?C?LIB_CODE
CODE    06E3H     0027H     UNIT         ?PR?PUTCHAR?PUTCHAR
CODE    070AH     0025H     UNIT         ?PR?MAIN?HELLO
CODE    072FH     0008H     UNIT         ?CO?HELLO
CODE    0737H     0006H     UNIT         ?C_C51STARTUP
        073DH     38C3H                  *** GAP ***
CODE    4000H     0001H     UNIT         ?PR?ISR41?HELLO

MORE INFORMATION

Article last edited on: 2005-07-15 13:22:21

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential