Ok,
In the listing he’s rotating left. I would think that would result in quicker times for the lower values.
I’m pretty sure there’s an error in my asm, as the example uses a different instruction to rotate with carry.
This is the same thing in BASIC but rotating right so the higher values should be found faster.
I’d be interested to enter a race with it.. just not sure some lines are converted the way I’d want them to.
Code:workword var word workbyte var workword.byte0 ‘ 1st byte bitcarry var workword.8 ‘ 9th bit bitcount var byte NCD8: bitcount = 8 ‘ mov l to w & w to f workbyte = portX ‘ mov l to w & w to f if workbyte = 0 then ‘ portX was zero goto whatawaste endif inloop: bitcount = bitcount - 1 ‘ decf workword = workword << 1 ‘ 2 x rrf with carry if bitcarry = 0 then ‘ btfss goto inloop ‘ goto endif return whatawaste: bitcount = 0 ‘ bsf return




Bookmarks