On Feb 11, 2014, at 1:24 AM, alan.b.pearce@stfc.ac.uk wrote: > I believe the free mode [of XC8] now does a minimal optimisation so that = any code generated will at least work in the way the code writer intended. I dunno. I downloaded the latest, in hopes that this would be true. But i= t's still producing rather weird code: >From one of their "blinky" examples: void delay() { int counter =3D 0; for (counter =3D 0; counter<10000; counter++) { ; } } 7FD8 0E00 delay MOVLW 0x0 ;; 16 bits of 0 to counter. 7FDA 6E02 MOVWF 0x2, ACCESS 7FDC 0E00 MOVLW 0x0 7FDE 6E01 MOVWF counter, ACCESS 7FE0 0E00 MOVLW 0x0 ;; and again (the source 7FE2 6E02 MOVWF 0x2, ACCESS ;; does it twice, too, so 7FE4 0E00 MOVLW 0x0 ;; I guess that's OK.) 7FE6 6E01 MOVWF counter, ACCESS 7FE8 5002 lp: MOVF 0x2, W, ACCESS 7FEA 0A80 XORLW 0x80 ;; Strange compare to 10000 7FEC 0F59 ADDLW 0x59 ;; I guess it's jumping through hoops t= o wind up with a sequence 7FEE 0E10 MOVLW 0x10 ;; that skips appropriately at the end= , rather than resolving 7FF0 B4D8 BTFSC STATUS, 2, ACCESS ;; the branch in the middle. But=85 = Eww! 7FF2 5C01 SUBWF counter, W, ACCESS 7FF4 B0D8 BTFSC STATUS, 0, ACCESS 7FF6 D003 BRA 0x7FFE ;; (exit) end of strange compare 7FF8 4A01 INFSNZ counter, F, ACCESS 7FFA 2A02 INCF 0x2, F, ACCESS ;; Pretty nice 16bit increment 7FFC D7F5 BRA 0x7FE8 ;; (lp) 7FFE 0012 exit: RETURN 0 --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .