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

"remainder of xdata"

I have a need for making a buffer, the size of which is as large as possible. I know how to do that in assembler; however, not in C. Two ways would work:

1) a pointer to the end of used xdata
2) an array my_array[MAX]

I much prefer method #1, but any method that will give me the desired result will be appreciated.

Thanks,

Erik

  • "2) an array my_array[MAX]"

    Or, how about just my_array[], and make sure that the linker locates it last - is that possible?

  • an array my_array[MAX]
    would allow locating it anywhere.

    Erik

  • Maybe if it is at the end of the last object-File to be linked:

    eofiles.c

    unsigned char last_xdata_byte[1];
    

    eofiles.h
    extenr unsigned char last_xdata_byte[];
    

    Linker-Command-line:
    L51.EXE [all the obj-files to be linked],EOFILES.OBJ
    

    But I'm not absolutely sure about it, so look it up
    in the linker's documentation and verify the result.
    This will NOT work if you use absolute memory locations
    which leave gaps in XDATA. In this case last_xdata_byte
    will be linked into the first gap.

    Maybe this would do:

    eofiles.c (corrected)
    #define MAX_GAP_SIZE 0
    unsigned char last_xdata_byte[MAX_GAP_SIZE+1];
    

    Norbert

  • Norbert, I have experienced that the Keil will rearrange variables if you change the name of one. I had to sanitize a program where the names were totally meaningless and wanted to do that with a .hex compare to verify that I did not make mistakes. In many instances when I changed a name the sequence of the variables changed.

    If someone knew the algorithm by which this happens, I could probably find a way e. g. if they are just alphasorted I could mame it zzz. However I will not make something that may fall apart when Keil releases a new version.

  • Hi eric,

    as far as I know reordering only applies to
    modules, compiled by C51.

    The ORDER-directive turn off reordering:

    #pragma ORDER
    

    However I referred to the ordering of segments:
    the suggested modul only contains 1 symbol, so
    the ordering of this Symbol within it's segment can
    easily be predicted :)

    The Linker processes the OBJ-Files "in the order
    in which they are specified on tthe command-line"
    .
    So the symbol's segment will be processed last if it is
    specified last. The maual doesn't exactly state, that
    it will be allocated last if it is processed last, but I guess
    you can assume this.

    Norbert

  • "but I guess you can assume this"


    That's the problem, I will not make something that may fall apart when Keil releases a new version.

  • Voilà one Reason, why we still use C51 V5.10.
    We are afraid of surprises.

    By the way:
    The assumption is definitely true for the combintion
    of partial code-segments (i.e. constant data in code).
    This is a feature on which Keil itself relies with their
    variable initialization routine ?C_START: a trailing zero
    linked at the end of ?C_INITSEG stops the initialization.
    It is also documented, that the customized STARTUP.A51's
    object file must be the last object file to be specified in
    the command-line.

    By the way. I think I remember that you've said, you have
    an assebler-solution to your problem. But to me this seems to
    be a linker problem, rather than a translator problem.

    So: How do you do it with the assembler?

    Norbert.