Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4745

Quickest way to get highest set bit on port in to a variable?

$
0
0
Hi.
I have eight sensors with digital output connected to a port and now I want to in the quickest way get only the highest set bit in to a variable.

if port = 110000
I want var = 000000

if port = 001111
I want var = 001000

So how can I do this in quickest(least amount of clock cycles) possible way?

Regards
/Matias

Viewing all articles
Browse latest Browse all 4745

Trending Articles