AnsweredAssumed Answered

[MDK5] Strange optimization

Question asked by stanzani.marco on Nov 24, 2015
Latest reply on Nov 25, 2015 by stanzani.marco
Hi there
I am struggling with a strange behaviour of Keil MDK (MDK5 to be precise)

   161:                     startAttemptsLeft --; 
0x08001B12 1E7F      SUBS     r7,r7,#1
0x08001B14 B2FF      UXTB     r7,r7
   162:                     shaftHaltedCnt = 0; 
   163:                     setPointIndex = 0;          
   164:                     setPointPeriod = setPointLUT[setPointIndex]; 
   165:                     delayBeforeShot = delayBeforeShot - (delayBeforeShot>>4); 
   166:         measuredPeriod = setPointPeriod ; 
   167:         hallToggleCnt  = 0; 
   168:                                 hallToggleCntRestartAttempts = 0; 
0x08001B16 2400      MOVS     r4,#0x00

This is a copy-paste from debugger disassembly window. It looks like C lines from 162 to 166 has been stripped out by the compiler, i.e. no assembly generated. This make no sense since the variables are used in the code afterwards. I tried to change the optimization level w/o success.

I am using Nucleo64 with STM32L0 MCU and MDK 5
I can post the full code but I do not want to begin with this.
Thanks to who'll help on this black magic

Outcomes