Bob Blick wrote: |Hi Everyone, | |Usually I don't pay any attention to optimizing code, if it works I use |it, but this morning I'm feeling picky. No where in my notes do I have a |decrement for more than a 2 byte number. I want 3 bytes. This is what I |came up with. It looks stupid to me. Feel free to come up with something |better. It's for midrange pics and does not use any temporary registers. | |movlw 1 |subwf low,f |movlw 0 |SKPC |movlw 1 |subwf mid,f |SKPC |decf hi,f | |Any improvements on this? | |Thanks, |Bob A simple improvement is to use the 1 which is already loaded in W to eliminate the second "movlw 1" instruction: movlw 1 subwf low,f SKPNC movlw 0 subwf mid,f SKPC decf hi,f Another alternative which cost 1 more ROM word and 1 extra cycle worst case, but saves 2 clocks 255/256 times, and does not modify W register would be: movf Low,f bnz X movf Mid,f skpnz decf High,f decf Mid,f X decf Low,f Chip Weller