Best I can think of is 3 assembler instructions, but more time than 3 cycles of course.
Copy the port value to a byte, count how many times you shift the byte right until the byte is zero.
If those times are for a single value,
I think it would be better than either example to check each bit in a verbose fashion still in the compiler.
Code:bytevar var byte ‘ buffer byte for port bitnum var byte ‘ output bit number that was set bytevar = porta btfsc _bytevar ,07 goto labelone btfsc _bytevar ,06 goto labeltwo btfsc _bytevar ,05 ......




Bookmarks