> From: Scott Dattalo > Subject: Shift right (or left) 4 > > How fast does your favorite shifting program shift a 32-bit unsigned integer > four bit positions? My first attempt yielded a 22 instruction slug, while my > second attempt is a 19 instruction screamer. Anybody have any idea on how to > make it scream louder? I don't know if you are trying to optimise size or speed. Luckily my simple solution improves on both. I haven't tested this! rrf hh, F ; move the whole chain down one bit, rrf mh, F ; / using the carry as temporary storage rrf ml, F ; / rrf ll, F ; / (repeat the above code three more times, and then) ; now, the top byte has four bits of rubbish at the ; top, so we have to clear them: movlw 0xF ; bit mask in W andwf hh, F ; set top four bits to 0 Total 18 words. If you are going for size optimisation, put the repeated section in a loop! Andrew Sharp Labs Europe Ltd, Oxford Science Park, Oxford, UK, OX4 4GA Andrew.Kay@sharp.co.uk Tel:+44 1865 747711 FAX:+44 1865 747717