SDCC : pic16/pic14 3.0.1 #6287 (Mar 14 2011) (Linux)
If I see the assembly code of my test program, I realize that the most important lines are commented out and it cause malfunctions in the result. This snippet want to toggle one bit. You can find three lines which want put the result to PORTC. I have chosen this way, because I wasn't getting trouble by read-modify-write sequence. This is not working because the first line compiled wrong. If I put something between these lines, the program is working correctly. That is why I think the problem could be around the optimization.
Here is the problematic part ( I removed the less important lines ):
;; 1109 rIdx = r0x104B
;; 1109 rIdx = r0x104D
;;1 MOVWF r0x1005
;; 1109 rIdx = r0x104C
;;101 MOVF r0x1004,W
;;99 MOVWF r0x1006
So W got ZERO and this ZERO is moving to the PORTC not the requested result. The second and the third lines from the source code is compiled correctly and It nice to see how SDCC can optimize my code. It is great! I didn't think SDCC could make it.
I attached a very simple test file.