At 12.17 2011.10.26, you wrote: >Em 26/10/2011 06:47, William "Chops" Westfield escreveu: >> 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. >> >> BillW >> > > >I agree. > >What the OP wants? The incriminated code was: digitalWriteFast(3,1); // compiles to LATxSET =3D b 9d00135c: 24020001 li v0,1 9d001360: 3c03bf88 lui v1,0xbf88 9d001364: ac6260e8 sw v0,24808(v1) digitalWriteFast(3,0); // compiles to LATxCLR =3D b 9d001368: 3c03bf88 lui v1,0xbf88 9d00136c: ac6260e4 sw v0,24804(v1 asm instruction #4 is redundant (IMHO even the #2, as a register should be devoted to store the SFR base at ~all times, as we're talking about a MPU here, not WindowsNT code in ring3). >I can see "load the bit mask" -> "load base address" -> "output the >value at base address+offset". >How could it be optimized further? Only if he preloads everything, but >then he would have two wasted registers. > > >Isaac > >--=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 .