PASM "REV"?
lardom
Posts: 1,659
in Propeller 1
Please help me understand what rev does in assembly. I can't make sense of the truth table or the explanation in the manual. I'm studying a quadrature encoder object from the OBEX and I'm stuck because I don't understand what that instruction does.
Thanks.
Thanks.
Comments
-Phil
The rev instruction looks like it's stated differentially which I find confusing but I think it's becoming clearer.
The first line reverses two bits and the second line reverses the sequence order of the quadrature code...I think.
Yes and no. The first line does reverse the two bits but the second line only inverts the lsb. Does the invert reverse the sequence order of the quadrature code? Maybe.
The description of the operation of REV is a bit confusing but knowing how it actually does operate sheds light on the explanation
So if in doubt you know that REV will shift right 30 places leaving only the 2 lsbs which were reversed.
-Phil
I know it's late but xor #1 only inverts the lsb or am I looking at some other code.
Oops! I didn't see the xor, assumed it was another rev! 'Haven't had my morning coffee yet.
-Phil
Well it's 3 in the morning here, I should get some sleep
I have a DC geared motor with an integrated quadrature encoder. It has two Hall sensors that read the edge of a disk. It is open collector which is something that made my eyes glaze over when I first got it in 2009.
I powered the 4-pin encoder connector with 5 volts from a Quickstart board and two wires from the "A" and "B" connections to two LED's. The LED's blinked and I didn't even need to write any code.
As easy as that was I could not have done that in 2009. Thanks for your help.
is a fixed wired permutation that reverses all the bits in a word, the barrel shifter is then applied to the
result. Its done this way to share CPU resources (the barrel shifter), so the instruction ends up being
a little non-intuitive - the argument is the number of bits to shift, not the number of bits reversed.
I now consider rev a useful instruction which I'll be using in the future. The author of the object which I'm studying made clever use of rev. My education continues...