William "Chops" Westfield wrote: > On May 27, 2011, at 2:47 PM, Gerhard Fiedler wrote: >=20 >>> PORTB |=3D 2 had better compile to a single BSF instruction when >>> possible (for example), or you go yell at the compiler vendor.) >>=20 >> [compiler documentation] should in enough detail address everything >> that is not standard C -- for example, how it handles bits, ports, >> stack, variable banks, recursion, pointers etc.=20 >>=20 >> Don't go yell at the vendor before having read the docs... :) >=20 > Current philosophy seems to be that a compiler should produce good =20 > code from STANDARD C constructs, without having to resort to non-=20 > standard bit-set macros. avr-gcc had deprecated sbi/cbi "functions" in =20 > favor of "just use var |=3D/&=3D~ bit", for example. This is probably true, and it is a good thing. However, it is still in "implementation-defined" land (that is, outside of what is specified in the C language standard), and if you want to know what your compiler does here, you have to consult the documentation.=20 For example, PORTB |=3D 2; resulting in a BSF instruction on a PIC is expected, but with PORTB |=3D 3; things are not so clear anymore. > After all, part of the point of using a C compiler is portability. > Non-standard architecture-specific features should be avoided > whenever possible. Yes, but so should be architecture-specific expectations -- unless they are founded in documentation or otherwise acquired knowledge of the specific compiler :) Gerhard --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .