Bit Reversal operation in basicatom pro

How to do bit reversal operation in basicatom pro?

Thank you.

I think you can do

a = a REV 8

The REV command is documented on page 42 of this manual:

Let us know if this works!

REV function is used to “reverse” the value of the low order bits of a number (i.e. change 0’s to 1’s and vice versa). Example:
x var byte
y var byte
x = %101110 ;this is decimal 46
y = x rev 3 ;gives g a value of %101001 or 41

I have read above function with example in Basicatom pro manual. It is not reversing the bits of a byte.

I tried using shift left operator. But how I can save Lsb of the original byte into msb of the reversed byte?

Thank you.

Again I am very very rusty when it comes to basic… You can do it manually with a loop something like:

[code]x var byte
y var byte
i var byte

x = %101110 ;this is decimal 46
y = 0

for i = 0 to 7
y = (y << 1) + (x & 1)
y = y >> 1
next[/code]
Again I am rusty here so could be issues