Bob Barr wrote: > On Tue, 10 Jul 2007 13:13:12 +0200, Hector Martin wrote: > >> peter green wrote: >>> IIRC C18 disables ALL optimisation in a function if you use any inline >>> assembler in it. I wonder if you are running into that issue. >> That's lame. Even so, it's not the issue. I wasn't using any inline asm. >> > > Compiler optimizations are performed based on the compiler's knowledge > of the state of things within the function. Since the compiler can't > "know" what any assembler code is doing inside the function, it has to > invalidate all of its assumptions. That's what actually disables the > optimizations. There are plenty of optimizations that can be performed even with inline asm in a function. Inline asm just invalidates the state _at that point in the function_, just like a function call would do (except a function call might push registers it uses on the stack, but this doesn't affect all optimizations). Disabling all optimizations is the cheap and lazy way out. GCC allows for inline asm, and I'm sure it doesn't magically disable all optimizations just because you use it. GCC even lets you specify what registers you're touching, and therefore maintains all others for optimization. It will even move your assembly code around if you don't tell it not to (if the assembly code is purely algorithmic calculations, it may be able to take it out of a loop, for example). And I still wasn't using any inline asm. No Nop() or ClrWdt() or any of those built-in macros. -- Hector Martin (hector@marcansoft.com) Public Key: http://www.marcansoft.com/marcan.asc -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist