alessandro carozzi

CodeWarrior for Coldfire v6.3 - Strange behavior with parameter passing

Discussion created by alessandro carozzi on Apr 2, 2007
Latest reply on Apr 3, 2007 by CrasyCat
Hi everybody,
I'm trying to understand (unsuccessfully, so far ...) what's going on in the following situation (I'm working on a MCF5213-based board and I'm using CW 6.3 - although 6.2 behaves exactly the same way).
Consider the piece of code shown in fig. 1 (see attached file). The function TestParameters() is declared as follows:

static int8 TestParameters(uint16 EEPROMAddr,uint8 *RAMAddr);

If I set a breakpoint on line (actually PC) 00007392 and then I go to line 000073D8, register D0 contains 0x00000000 (see fig. 2) so the value passed to TestParameters() (move.w d0,(a7)) as first parameter (i.e. EEPROMAddr) is 0. This value is WRONG (the correct value is 0x00000100 as PageCount is 0 and EEPROMSettings is 0x100) and so TestParameters() incorrectly reports an error.

If instead I set a breakpoint on line 00007392 and then I single-step to line 000073D8, register D0 contains 0x00000100 (see fig. 3) so the value passed to TestParameters() as first parameter (i.e. EEPROMAddr) is 0x100, which is correct.

Needless to say (Murphy's Law), when the program runs at full speed it behaves incorrectly (as in the first case above).

Other interesting facts are:

1) If I change the link order just by swapping the position of two files, the correct parameter gets passed to TestParameters().
2) If the program is even slightly changed (i.e. some code is either added or removed), the correct parameter gets passed to TestParameters().

Thanks in advance for your help !

Alessandro

Message Edited by CrasyCat on 2007-04-02 11:31 AM

 

Code.doc

Message Edited by t.dowe on 2009-10-29 09:43 AM

Outcomes