Hi,
I'm using the keil to compile a project for the 8051.
I want to place a single function in a specific address in the rom.
I found a lot of answers, in the forum, but non of them actually worked.
How can i "tell" the keil that the specific function MUST be at address 0x1234, for example? if it helps, the function is written in a seperate file. Thanks, Noam
Why do you not start by telling why you want your function located at a fixed location?
A lot of people why try to place a function at an absolute location tries this without really needing it!
"A lot of people why try to place a function at an absolute location tries this without really needing it!"
Very true!
But, even if you are one of the rare cases where it really is necessary, people still need to know the reason in order to give appropriate suggestions.
Some possible approaches may not be appropriate to your specific requirements - which may also be why what you've tried so far hasn't "worked".
It'd also be helpful if you explained what you'd tried and why (you think) it didn't "work"...
As ever, the more effort you put into giving a complete question, the more likely you are to get a useful answer!
The reason why i need it is: The compiled code is be placed in a ROM. Fixing bugs will be done by fixing the bugged function in a RAM (and dedicated hardware will make sure to bring data from the RAM instead of the ROM when approaching the bugged function). This RAM is located in address 0xa000 (the ROM's address space is from 0x0000 to 0x9fff). I need to recompile the original code (with the bugged function) but to add to it a fixed function that is written in C (that MUST be placed in address 0xa000).
This is the reson why i need to place a certain function in a specific address. BR, Noam
Wouldn't it be easier just to have the entire code in RAM for debugging?
The more "special cases" you have to make just to debug, the less representative your debugging becomes!
This was the whole point of the "ROM Emulator" concept...
Life isn't that simple.
To get a fixed function to place in RAM, you must recompile.
But when you recompile, the original space for the buggy function will be reused by other functions in the recompiled binary.
Your new - fixed - function that you place in RAM, will try to access functions in ROM based on the new compilation - not the original compilation. But since you haven't reporgrammed the ROM, all references from the RAM function must also be redirected. However, they can't simply be redirected to absolute locations, but be remapped to the original location in the original ROM image.
How many redirects can your dedicated hardware support? You should be ok if you can handle maybe 10 - 100 redirects, but you have to retrieve the redirects from the map file. And you may be more or less dead if the references are not to the entry points of functions.
Remember that if the compiler/linker is smart, it may locate common function tails, and let one function jump into the middle of another function just to process the last instructions.
What happens if any function tries to jump into the middle of this modified function, expecting to find an identical tail?
Andy, the size of the RAM is 10 times smaller than the ROM (as you probably know, ROM consume significantly smaller space - this is the only reason to use it from the first place). The RAM's purpose is to fix bugs in specific functions.
Per, do you think that, assuming I didn't change anything in the original code and assuming I didn't add additional variables in the fixed function (the code with the bug). The only thing I would do is to add additional function that will placed in 0xa000. Do you think it will change the compilation of the original code? the fixed code and the original code are not even in the same address space, why should it change the compilation of the original code?
I want to give it a try. do you know how can i place the fixed function in a specific location (0xa000)?
"this is the only reason to use it from the first place"
No, in general it's not the only reason - the other reason is that it's non-volatile!
In general, for test/debug purposes, you would remove the ROM and replace it with RAM or a "ROM Emulator" or somesuch.
"do you know how can i place the fixed function in a specific location (0xa000)?"
What have you tried so far? In what way(s) did that "not work"?
View all questions in Keil forum