C51: ADDING TO THE STARTUP CODE
Information in this article applies to:
How do I add code to the startup routines so that it executes before the main C function?
The startup code is very easy to modify. First, you must copy the proper startup code into your project folder and add it to your project.
Then, you must add your code to the correct place in the startup code. The following listings show excerpts from the startup code.
CSEG AT 0 ?C_STARTUP: LJMP STARTUP1
This is the RESET vector. On the 8051, the reset vector is located at address 0000h (unless it has been moved to work with a target monitor or boot loader). Note that the reset vector is simply an LJMP to the startup code. The reset vector MUST be an LJMP because the first interrupt vector is located at address 0003h.
RSEG ?C_C51STARTUP STARTUP1:
The next lines of code define a relocatable segment (named ?C_C51STARTUP) and a label (STARTUP1). Note that this is the label that the reset vector jumps to. Your initialization code should typically go immediately after this label.
The following Discussion Forum threads may provide information related to this topic.
Last Reviewed: Saturday, May 1, 2004
of your data.