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

Override / replace multiplication routines from library

Hello,

I am developing an 8051 system / chip where I want to put the multiplication/division routines in a ROM.
The real program should then call these routines instead of adding the library to the code.

For UART I exchange/override the getchar/putchar library routines with own ones.
Is such an approach also possible for the multiplication routines?

The fallback method would be to define all possible multiplications/divisions as functions. And replace all * / with rom function calls. This increases the call overhead and I would write the code in a special style. This is what I want to avoid.

Thanks and BR, Joachim

Parents
  • Hello,

    That's a good idea. At least for multiplication this should be possible.

    Nevertheless I already got it to run in a different way.
    I utilized a union located at a fixed position and size (reserved in both program parts) containing structs for each function in ROM for parameter passing
    and the functions should only use R0-R7 (checked manually in assembly code - maybe there is an automatic way?).
    The only critical thing is if R0-R7 hold variables in the calling program part that are overwritten (Compiler does not know which registers are modified).
    Until now I could not see a problem, but maybe somebody has here a better experience with that.
    If this does not work the solution would be to switch the register bank and reserve this bank iram locations as fixed global variables in the flash image.

    Many thanks for your help and suggestions.
    BR, Joachim

Reply
  • Hello,

    That's a good idea. At least for multiplication this should be possible.

    Nevertheless I already got it to run in a different way.
    I utilized a union located at a fixed position and size (reserved in both program parts) containing structs for each function in ROM for parameter passing
    and the functions should only use R0-R7 (checked manually in assembly code - maybe there is an automatic way?).
    The only critical thing is if R0-R7 hold variables in the calling program part that are overwritten (Compiler does not know which registers are modified).
    Until now I could not see a problem, but maybe somebody has here a better experience with that.
    If this does not work the solution would be to switch the register bank and reserve this bank iram locations as fixed global variables in the flash image.

    Many thanks for your help and suggestions.
    BR, Joachim

Children
No data