I'm trying to locate the INIT.A51 code in a specific spot and I cannot figure out how to do it. I can locate STARTUP.A51 where I want it by added this to the BL51 tab in UV2: ?C_C51STARTUP(2000h) It does locate there as expected, but then in that code there is this asm instruction towards the end of the file: LJMP ?C_START which jumps to the file INIT.A51 (which eventually jumps to MAIN) The order of the code in memory is roughly like this: C_C51STARTUP MAIN C_START Every time I edit the size of MAIN(), the address of C_START changes. I need them to be in this order: C_C51STARTUP C_START MAIN so the two assembly files are next to each other and before MAIN(). How can I do that? I've looked at the map file and I don't even see the starting address for C_START.
The startup code STARTUP.A51 and the initialization code INIT.A51 are both stored in the same segment (?C_C51STARTUP). The C_START is a label used in the initialization code. However, C_START is a label and not a segment. That's why you can't locate it to a different address. If the STARTUP.OBJ and INIT.OBJ files are not linked together, the linker MAY be locating them non-contiguously. Have you tried including both files in your project one right after the other? I created a simple program:
unsigned char bigbuf [] = "This is a test"; void main (void) { }
* * * * * * * C O D E M E M O R Y * * * * * * * CODE 0000H 0003H ABSOLUTE 0003H 3FFDH *** GAP *** CODE 4000H 008CH UNIT ?C_C51STARTUP CODE 408CH 0012H UNIT ?C_INITSEG CODE 409EH 0001H UNIT ?PR?MAIN?MAIN
Well the thing you mentioned I guess is my only hope: "including both files in your project one right after the other." By keeping STARTUP.A51 and INIT.A51 next to each other in the project source group list, it seems to be working ok. When they were separated in th list, they located around my main code instead of before it. Thanks.