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.
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.
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.
Last Reviewed: Thursday, February 25, 2021
of your data.