Hi, In our project we are using function pointers. After compiling the project, we got "RECURSIVE CALL TO SEGMENT" warning. By selecting OVERLAY (sfname ! *)in BL51, that warnings was removed. If we add function name in OVERLAY, will it allocate diffrent memory for local variables and function argumants?. How it is diffrent from by difining same function as rentrant function ?. Thanks in advance..
Rajesh, I'm really no expert on the topic, but I'll give it a crack. When you specify a function as "reentrant," you're telling the compiler NOT to pass function arguments in registers. This means that the compiler will generate code to behave more like a PC in that it will push arguments onto the stack and the function will pop them off. This is MUCH slower and more resource intensive than the standard methodology used by C51. Manually modifying the OVERLAY entries to fix problems caused by, say, function pointers has to do (as you rightly guessed) with how the compiler handles local variables. Normally, local variables for functions would be overlayed in all cases where on function doesn't call another, etc. to conserve memory space. When you use pointers, the compiler cannot figure out if/when you have called that function. This directive tells it just to be safe and not overlay the local automatic variables for that function with ANYTHING at all.
Thanks Jay Daniel. So, Which are the functions are being called indirectly(through function pointers)are should be defined using OVERLAY directive. we need not to define it as reentarnt. Am I missed any thing, please comment on this... Thanks Rajesh
Rajesh, I believe the general idea is that you can do one of two things. The first is to specify for the compiler which modules it should just skip doing overlaying for altogether. The other method is to take a look at your code and use the OVERLAY directive to help the compiler finish the call-tree that it would be otherwise unable to generate. As for the specifics, you'll have to look in the manual. If I could suggest an alternative, however: Could you simply use another function as a "dispatch" function that takes a parameter. For instance, you're using function pointers so that you could do something like:
functable[i]()
void dispatcher(unsigned char i) { switch(i) { case 1: a(); break; case 2: b(); break; } }
View all questions in Keil forum