We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
But how little RAM do you have - note that there are options to just run individual functions in RAM. The linker can set up the binary so that the C runtime library will copy the code implementation for specific functions into RAM at the same time as it initializes global variables.
This is regularly used when an ISR or maybe a DSP inner loop is extremely time-critical - RAM normally represents the fastest memory region available.
Just that not all processors can run code from RAM. And some processors might have lots of RAM but only some of it able to run code - it's a question of caching and interaction with the pipeline.
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