How to link ? Help !

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

Parents
  • 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.

Reply
  • 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.

Children
No data
More questions in this forum