|
How to link ? Help !Next Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Stephane REY Posted 27-Aug-2002 13:00 GMT Toolset C51 |  How to link ? Help ! Stephane REY I'm using the uVison 1 and I'd like to build my project. My example project should include the CSTARTUP.OBJ and some compiled C files
There is two methods : 1. with IDE 2. with command line
For both, I've some troubles, may someone help me ?
1.With IDE ----------
When linking a project with more than one function, the main function is no longer located to 0000h. So I d'like to include the CSTARTUP file where I wrote :
NAME ?C_STARTUP
?C_C51STARTUP SEGMENT CODE
?STACK SEGMENT IDATA
RSEG ?STACK
DS 1
EXTRN CODE (main)
PUBLIC ?C_STARTUP
CSEG AT 0
?C_STARTUP: LJMP main
But I didn't found in the options of the IDE uVision 1 how to include the CSTARTUP.OBJ in my linking commands and how specify where it should be located ???
2. With command line --------------------
So I've linked with the following command line : BL51 @lnk.lnk where lnk.lnk is a command file including :
C:\TRX8051\CSTARTUP.OBJ, &
C:\TRX8051\MAIN.OBJ, &
C:\TRX8051\HLCD.OBJ, &
C:\TRX8051\INIT.OBJ, &
C:\TRX8051\RREX.OBJ &
TO C:\TRX8051\TRX8051 &
IX NODS NODP NODL NLIB RS(128) PL (68) PW(78)
and then executing OH51 to convert into Hex file.
The problem is : how to specify that CSTARTUP should be located to 0000h and then jump to the main() function ???
Thanks for your help Stephane | | Read-Only Author Mark Odell Posted 27-Aug-2002 13:37 GMT Toolset C51 |  RE: How to link ? Help ! Mark Odell main() should never be located at 0x0000. 0x0000 is the reset vector. main() cannot be called until the C run-time has executed. Typically the C run-time copies the .data section variables from ROM to RAM, zeroes the .bss section, sets the stack pointer and any other CPU registers appropriately, and *then* calls main().
Since the C run-time must run before main() it follows that it should be located at 0x0000 and main() just goes where ever it goes. The Keil C run-time is automatically linked against so it should be there. If you wish, you can override it or see what it does by looking at cstartup.a51. | | Read-Only Author Alan Chen Posted 27-Aug-2002 15:09 GMT Toolset C51 |  RE: How to link ? Help ! Alan Chen But I didn't found in the options of the IDE uVision 1 how to include the CSTARTUP.OBJ in my linking commands and how specify where it should be located ???
You are already doing it by saying:
CSEG AT 0
?C_STARTUP: LJMP main
I think you might be a little bit confused about an object file and an actual code segment. You can't locate an object file to a particular location, but you can locate a segment of object code to a particular location. For example, you can locate your main() to program memeory 0x0100 by adding this line to your ink.ink
code(?PR?MAIN?MY_FILE_NAME(0x100))
These two articles may help you:
http://www.keil.com/support/docs/2156.htm
http://www.keil.com/support/docs/2263.htm
| |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|