AIM

MSN

Website URL

ICQ

Yahoo

Jabber

Skype

Location

Interests

Bug description:
The same source code line generates different assembly code in different places. Sometimes the generated code is incorrect, sometimes it is correct.
Steps to reproduce:
Use the same source code in 2 different places in the source.
Detailed description to reproduce this problem I use this statement in two different places in my source code -
WatchdogTarget = CONST_WDT_MINTIME + (Trembler & 0x07);
CONST_WDT_MINTIME is a constant -
#define CONST_WDT_MINTIME 1U
The first time it is used, the following code is generated (which looks correct) -
01D7 3007 MOVLW 0x7
01D8 0547 ANDWF 0x47, W
01D9 00CA MOVWF 0x4A
01DA 0A4A INCF 0x4A, W
01DB 00C4 MOVWF WatchdogTarget
The second time is it used, the following code is generated (which is not correct as it modifies the value in "Trembler" at 0x47) -
020A 3007 MOVLW 0x7
020B 05C7 ANDWF 0x47, F
020C 0A47 INCF 0x47, W
020D 00C4 MOVWF WatchdogTarget
Expected behaviour:
This is the code I would expect to see -
020A 3007 MOVLW 0x7
020B 05C7 ANDWF 0x47, W
020C 0A47 ADDLW 0x01
020D 00C4 MOVWF WatchdogTarget
The compiler should not modify the value of "Trembler" at 0x47 (and as the value of CONST_WDT_MINTIME may be other values at compile-time)
If CONST_WDT_MINTIME was (say) 32, I would expect to see this instead -
020A 3007 MOVLW 0x7
020B 05C7 ANDWF 0x47, W
020C 0A47 ADDLW 0x20
020D 00C4 MOVWF WatchdogTarget
Is the problem 100% reproduceable: Every time
IDE version: MPLAB-X 4.0
Compiler: BoostC++
Compiler version: 7.42
Target device: PIC12F635
OS: Windows 7 64-bit