In SX Microcontrollers, SX/B Compiler and SX-Key Tool, dabayliss wrote: Two decades as a compiler writer does odd things to your brain; I dream about this sort of stuff :freaked: Actually, I missed a trick too ... now 5 words mov w,<<encbits xor w,encbits and w,#2 add enc_a_count,w dec enc_a_count Same idea as before but accumulate the result in bit 1; allows the double add to be done in one instruction ... David [quote="madcows"] [quote="David Bayliss"] I don't know how important performance is; but for this particular case there is a slightly faster solution (single word instructions/no jumps or skips) if you don't mind trashing w: mov w, >>encBits xor w, encBits and w,#1 add enc_a_count,w add enc_a_count,w dec enc_a_count David [/quote] Wow! It took me a second to try to figure out why you were adding w twice, then performing a subtraction. Finally, zoot's version makes sense to me too! I don't know how some of your brains figure this stuff out! This certainly helped expand my mind on sx assembly, and logic. Thanks, Mark S[/quote] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=331284#m331870 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)