This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I need to move the C Library functions to a different memory area

Hi,

I've got a program getting the startup code to locate in the proper place because its being displaced by the C Lib module

Here's a mapfile snippet


* * * * * * * * * * *   C O D E   M E M O R Y   * * * * * * * * * * * * *
000000H   000002H   000003H   BYTE   OFFS..   CODE           ?C_CPURESET?0
000003H   000022H   000020H   ---    ---      **GAP**
000023H   000025H   000003H   BYTE   OFFS..   CODE           ?SYS_SERIAL0?00023
000026H   003FFFH   003FDAH   ---    ---      **GAP**
004000H   004176H   000177H   BYTE   UNIT     CODE           ?C?LIB_CODE
004177H   0042A9H   000133H   BYTE   UNIT     CODE           ?C_C51STARTUP
0042AAH   0042BEH   000015H   BYTE   UNIT     CODE           ?C_INITSEG

And the memory map:
BASE        START       END         USED      MEMORY CLASS
==========================================================
X:000000H   X:00A000H   X:00FFFFH   00078BH   XDATA
X:000000H   X:020000H   X:03FFFEH   000401H   HDATA
C:000000H   C:004000H   C:009FFFH   0002C5H   CODE
C:000000H   C:010000H   C:01FFFFH   0007C1H   ECODE
C:000000H   C:004000H   C:00DFFFH             HCONST
I:000000H   I:000000H   I:0000FFH   000001H   IDATA
I:000000H   I:000000H   I:00007FH   000018H   DATA

I need to get the C51Startup module to 0x4000

I'm using a slightly altered version of the auto-generated startup.a51. The alterations are fairly trivial, no new segments.

I have tried appending the segment declaration of C51Startup with 'at 0x4000' and the linker really does not appreciate it.

The best I've managed like that is to get the CINIT_SEG to locate at 0x4000 then came CLIB, etc...

Yesterday I managed to fudge things by declaring ECODE from 0x4000 and moving the CODE area somewhere else but this didn't seem to be a good idea in the long run. Also can't replicate it now (...and before anyone says I know I should have taken copy when it was working...How many years have I been doing this!)

Anyway cheers for any help

Bernard

Bernard

  • Why should 0x4000 be the only proper address for the startup code? It really shouldn't matter where it goes, as long as the reset vector at 0x0000 is set correctly, which I'm quite sure the linker will manage to do regardless of where the startup code ends up.

    And BTW, startup.a51 isn't really "auto-generated", it's written by hand by Keil people, and then either the source is copied into your project, or a compiled version of the master copy itself automatically added to the link.

  • Why should 0x4000 be the only proper address for the startup code? It really shouldn't matter where it goes, as long as the reset vector at 0x0000 is set correctly, which I'm quite sure the linker will manage to do regardless of where the startup code ends up.

    I realised that after posting. The 'reason' (if it can be called that) is I'm moving across from SDCC to Keil and just been keeping with the same settings. It doesn't need to be that high but with the DS80C400 part of the ROM startup writes over the lower part of the RAM (certainly the interrupt vector table) and so you have to leave a gap.

    Anyway we've managed to get that part working, just got the TINI ROM interface function to go, having problems getting the parameters off of the stack and setting up the return values.

    Thanks for your help.

  • Use CODE(0x4000,?C_CSTARTUP) for the linker. This specifies that the CODE area starts at 0x4000 and that the first code segment should be ?C_CSTARTUP.

    Jon