Skipped instructions in debugging

Dec 10, 2006 9 Replies

I am debugging a program in C for Chipcon 2430 processor in IAR Embedded Workbench. When I run the program step by step, I observe that the execution cursor jumps over some instructions and they never get executed. What could be the reason for this? A memory mapping issue? Stack corruption?



Nina


... which is an 8051, n'est-ce pas?

Are you sure they never get executed? Since you are programming in C, single-stepping the program might mean single-stepping through the SOURCE line-by-line, which is not the same thing as single-stepping the assembly output.

Do you mean at ASM level, or at HLL/C level ? Have a careful look a the instructions. Some instructions will execute before a debug-trap occurs - ones that access interrupt resource often fall into this class.

An easy way to check this type of behaviour, is set a break point after the code block, and inspect the accessed SFRs/memory.

-jg

Yes.

execution

could

The debugger provides a panel with the assembly code. I observe that no assembly output is generated for the skipped lines.

Thank you,

Nina

execution

could

The debugger doesn't show any assembler output for the skipped lines.

Thank you,

Nina

Do you have optimisation set to 'none'? Even when this is the case I have seen the IAR compiler remove obsolete code. Also the chipcon libraries #define the same name to many different things depending on other definitions making it difficult to see exactly what should be executed. Some definitions are null so will not generate code.

Regards, Richard.

  • formatting link
  • formatting link
    for Cortex-M3, ARM7, ARM9, HCS12, H8S, MSP430 Microblaze, Coldfire, AVR, x86, 8051, PIC24 & dsPIC

Thank you, this helped.

Amazingly, the optimization was one of the first things I was about to check but then it escaped me...

Thank you,

Nina

Then there is nothing to single-step for the skipped lines. They are presumably #define'd out or consist of macros that do nothing.

Look at the code. Do nothing code gets removed during optimization. Redundant code gets combined. Single -stepping optimized code can be confusing sometimes.

I don't know that this is the case for your particular CPU, but another possible issue is the "Branch delay slot" on some CPUs.

Just before executing a branch, the instruction immediately after it also executes. If that happens, you might not see it in your debugger.

Just my .002 cents / kilobyte.

--buddy

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required