Keil Logo

C51: RESET VECTOR DOES NOT JUMP TO C CODE


Information in this article applies to:

  • C51 Version 5.50

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 \LIB\STARTUP.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 \LIB\INIT.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

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.