At 10.47 2011.10.26, you wrote: > >On Oct 25, 2011, at 4:23 AM, Electron wrote: > >>> >>> digitalWriteFast(3,1); // compiles to LATxSET =3D b >>> 9d00135c: 24020001 li v0,1 >>> 9d001360: 3c03bf88 lui v1,0xbf88 >>> 9d001364: ac6260e8 sw v0,24808(v1) > >>> that was digitalWriteFast, I have seen more horrific output from =20 >>> the compiler. > >That does look pretty optimal for setting an output pin; I'm happy =20 >(aside from the lack of optimization when manipulating other pins =20 >"nearby" in the code.) (digitalWriteFast() is a macro to implement =20 >the digitalWrite() "standard Arduino function" when all the arguments =20 >are constants. A horrible kludge depending on gcc features and =20 >compile-time optimization. But about 20x faster than the function. A but OT: for a start, I think it makes a sense to devote on of the 32 CPU regs to the SFR base ( @ BF88 ). In the original code (not shown above), LUI V1,0xBF88 is repeated every time. Ok, probably with the optimizer on (which is only available for 60 days for common mortals) it will be eliminated, but then again I decided to use asm as a main language on the PIC32 (and eventually add some C functions where necessary) and devoting a CPU reg for the SFR base looked like a good idea to me (if I'll ever need that reg, I will use it and then restore it to the SFR base). Also, I don't like that the SFR's are linker objects, I am making a set of includes ( _LATDINV, etc.. ) to be used as offsets for the SW. Cheers, Mario > >BillW > >--=20 >http://www.piclist.com PIC/SX FAQ & list archive >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .