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

improper flow of control

Hi all,

I am using the microvision 2 and the controller is c8051f12x. I faced a strange problem with keil.

Have a look at the following sample code.

void main()
{
f1();
f2();
f3();
}
void f1()
{
// some code
}

void f2()
{
// some code
}

void f3()
{
// some code
}

when debugging, in the main(), instead of calling f1(), it is calling f2() and in the mid of executing f2() it is jumping to the mid of f3() and returning to f1() and then to main().

This is only a sample. Actually the control is jumping improperly.

Has Anyone faced such problem? How this can be resolved?

Thanks in advance,
Neo

Parents
  • "I'll test it with lower optimisation levels."

    If it works on lower optimisations, you have one of two problems:

    (1). Your code relies upon something that it shouldn't, but that happens not to matter at low optimisation (ie, your code works by luck);

    (2). You have found a situation that confuses the optimiser.

    If you suspect (2), you should start by examining the compiler's generated assembler and the disassembly generated by the Linker in its .COD file.

Reply
  • "I'll test it with lower optimisation levels."

    If it works on lower optimisations, you have one of two problems:

    (1). Your code relies upon something that it shouldn't, but that happens not to matter at low optimisation (ie, your code works by luck);

    (2). You have found a situation that confuses the optimiser.

    If you suspect (2), you should start by examining the compiler's generated assembler and the disassembly generated by the Linker in its .COD file.

Children
No data