Reversing (mirroring) copy of a specified number of bits
Chuck H-M
Posts: 1
In my old Basic Stamp Manual, Version 1.9. On·pgs 239 & 245 there is a REV command, which will supposedly do this.· If my variable word is "wordout", and I want to reverse only the last 12 bits, how do I use the REV command?
Comments
x = %0110111011110001
DEBUG CR,BIN (x REV 12) ' prints 100011110111 reversal of 12 lsbs
DEBUG CR,BIN12 (x REV 16) ' prints 111101110110 reversal of 12 msbs
Note that REV is a binary operator. There are other combinations you might want, for example, to reverse the 12 least significant bits but keep the 4 msbs the same:
DEBUG CR,BIN16 (x REV 12) | (x & $F000)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com