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

Questions about linker/relocator

Hi everyone,

in my projects j often use the philips 87LPC764 (8051 derivative low pin count). The micro is good but it has only 4K of code memory, so j'm always searching methods to compact my code as much as possible.
In one project j use some modules written in assembler, and since the total amout of code of that modules is less than 2K j tried to use AJMP and ACALL to save memory.
Unfortunately the linker locates somewhere in memory the modules so j must use JMP and CALL to correct the situation.
J used a little trick to correct it, in the project j loaded first the assembler modules and after the other.
The linker seems to link modules in order and this trick functions good, but my answer is : How to get the modules located in low 2K of memory using a more elegant and/or fast method???
Thanks in advance.

Sorry for the long post!!!!!

  • Are you using the Evaluation version?

  • Hi!

    J'm using the standard version 7.00 without the 2K code limitation!

  • In C, use ROM(COMPACT). In assembler, be sure to create your segments using INPAGE.

    Jon

  • J searched in the manuals but j found only a very short description of directive INPAGE, but it seems applicable only in segmentes of 256 bytes maximun!
    Anyway reading accurately the manuals j found a way to solve my problem.
    In the uVision environment in "Options for target" -> "BL51 Locate" -> "Code" you can specify the order of relocatable segments, j write here the name of my asm modules and the relocator locate then in the low part of the code memory.
    So since the total amount of this modules is less tan 2K code j used AJMP and ACALL to reduce size of the generated code.

    Anyway thank you for the suggestion!

  • INBLOCK works, but my problem is to have BOTH my assembler modules locate in the SAME 2K block.
    J tried INBLOCK but the linker gives me the "improper fixup" error because it does not locate the modules together and some ACALL's refer to an address far more than 2K.
    j think the better solution for this problem is specifying the order of relocation as j explained in my previous post.

  • Why not use the CALL and JMP generic pseudo instructions, and let the assembler decide which real instruction to use?

  • J try to explain better my problem:
    j have a project composed of some .c modules and 2 .a51 modules. In order to compact the code j had the idea of using
    only ACALL and AJMP in my assembler modules, because this istructions are shorter than LCALL and LJMP. However this
    istructions work only in a 2K code block, so j searched a way to force the relocator to put the 2 modules in the lower
    2K of code memory.
    In this way j'm sure j can use AJMP and ACALL (the total size of the modules is less than 2K).
    To obtain this the better solution j find is the one j wrote in the my previous post : from the uVision environment
    in "Options for target" ->"BL51 Locate" -> "Code" you can specify the order of relocatable segments.

    J hope it's more clear now.

  • "this istructions work only in a 2K code block, so j searched a way to force the relocator to put the 2 modules in the lower
    2K of code memory."


    They work within any 2K block - there is no need to restrict it to the bottom 2K!

    Did you make sure to use both ROM(COMPACT) for the 'C' code and INBLOCK for the assembler?

  • "They work within any 2K block - there is no need to restrict it to the bottom 2K!"

    Yes, you are right! But the problem is to have BOTH modules in same block, because some functions in module N° 2 call functions in module 1.

    "Did you make sure to use both ROM(COMPACT) for the 'C' code and INBLOCK for the assembler?"

    Yes j did it. For ROM(COMPACT) there was no problem, but when j use INBLOCK j get a "improper fixup" error from the linker.
    J think the problem is that modules are relocated in a 2K block, but NOT the SAME block.

    My solution it's a simple trick but it works (j tested it)!