Hello all, We have a strange problem. During execution of a function, the control goes to some different line in a different function, without making a call it... I will try to explain the scenario with an example.... Say we have a function A (30 lines) and a function B (say 30 line too). During the execution of the function A, say it is in line 18, it jumps to some line (say 23) in function B.....No call is made to function B in function A. And this happens exactly at the same line everytime we run the program. There are no calls to any function in A....just some calculations, some if statements...etc. No function calls in A. We have some function pointers in our program, we have read the related documents in the keil knowledge base. We have added the necessary linker settings, to modify the linker call graph. So as far as the settings are concerned, we have made all the linker settings and confirmed it with the resulting MAP file. The call graphs is as expected.... Can there be any other reasons for the cotrol to jump in the above manner...??? Code size is well below 64K, so we are not using code banking. regards prasanna
During execution of a function, the control goes to some different line in a different function, without making a call it... And how do you notice that? Did you look at the actual machine code, or just step through in the C source view of the debugger? What's your optimization level? Are you sure you understand what the different optimization levels can do to your program? We have added the necessary linker settings, to modify the linker call graph. ... and you're sure you got those right?
I have actually looked into the "Asm" mode, it does show the actual next instruction to be executed, but when i press F10 (while step debugging) it jumps to the other function..... The linker settings are correct, as i checked the MAP files, and had read the knowledge base articles on how to add these settings when using indirect function calls... the Map file is correct.... thanks and regards
The optimization level is Maximum (9) and we have selected Favor Size....as our code size in the actual program is huge and we are using code banking in the actual program. regards
Which 'asm' exactly did you look at? For this to be meaningful, it'd have to be the disassembly inside the debugger, and you'ld have to F11 through that, at the critical location. My guess is you're just seeing the effect of OT(9) (common block subroutines), i.e. equivalent code in your two functions was noticed by the compiler and turned into a single subroutine. Trying to debug that kind of compiled code at source level is not likely to work well.
>>>Which 'asm' exactly did you look at? For this to be meaningful, it'd have to be the disassembly inside the debugger, It was the asm in the disassembly insided the debugger.....as i mentioned earlier, it does show the next instruction which is the actual next line in the function, but when i do a F11, it jumps to the other function.... During debugging i also tried to use the yellow arrow mark, which is used to show"next instruction", which points to the actual next instruction in the function. But F11 takes it to the other function.... regards
this is as it should be let us say you have 2 functions func1 X: do a Y: do b Z: do c return and func2 P: do d Q: do e R: do c return the optimizer will change func1 as follows: func1 X: do a Y: do b GOTO r: which saves codespace. Erik
Not exactly....i mean....the Func1 is actually a routine to write on the SMBus. I am using C8051F130.... And the function where it is jumping to, is the Port initialization function, were we are initialization the ports, the crossbar, emif....etc. There is nothing common in between Function 1 and Function 2..... regards prasanna