locating INIT.A51 in UV2

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.

Parents
  • 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)
    {
    }
    

    that generates the following Code Memory Map in the M51 map file:

                * * * * * * *   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
    

    There are 2 segments that you should worry about: ?C_C51STARTUP (this contains the code from STARTUP.A51 and INIT.A51) and ?C_INITSEG (this contains the data that is used to initialize global and static variables).

    Refer to the following knowledgebase article to see how to locate these:

    http://www.keil.com/support/docs/940.htm

    Jon

Reply
  • 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)
    {
    }
    

    that generates the following Code Memory Map in the M51 map file:

                * * * * * * *   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
    

    There are 2 segments that you should worry about: ?C_C51STARTUP (this contains the code from STARTUP.A51 and INIT.A51) and ?C_INITSEG (this contains the data that is used to initialize global and static variables).

    Refer to the following knowledgebase article to see how to locate these:

    http://www.keil.com/support/docs/940.htm

    Jon

Children
More questions in this forum