How can I flip bits in SX/B?
T&E Engineer
Posts: 1,396
If I have a variable tmpB3 which·let's say looks·something like this: %11001010 and I want the bits to be fliped so it now is: %01010011
How can this be done?
More specifically·I have a data statement with a character (or really lots of characters in DATA statements):
UC_Letter_A:
DATA· %01111100 'A
DATA· %00010010
DATA· %00010001
DATA· %00010010
DATA· %01111100
and I don't want to have to retype every character in flipped again but I need this:
UC_Letter_A:
DATA· %00111110·'A (flipped bits)
DATA· %01001000
DATA· %10001000
DATA· %01001000
DATA· %00111110
There should be a way to read it in and flip the bits. How can this be done in SX/B 2.0?
Thanks for your help!
·
How can this be done?
More specifically·I have a data statement with a character (or really lots of characters in DATA statements):
UC_Letter_A:
DATA· %01111100 'A
DATA· %00010010
DATA· %00010001
DATA· %00010010
DATA· %01111100
and I don't want to have to retype every character in flipped again but I need this:
UC_Letter_A:
DATA· %00111110·'A (flipped bits)
DATA· %01001000
DATA· %10001000
DATA· %01001000
DATA· %00111110
There should be a way to read it in and flip the bits. How can this be done in SX/B 2.0?
Thanks for your help!
·
Comments
Of course, you can write a function with two bit masks if you need to operate on a wide swatch of variables with variable reverse counts and lengths (a la the Stamp REV operator), or you can use two other temps or a local stack and load 'em up as parameters...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
I thought about Zoot's first approach but was locked into thinking I could use a FOR NEXT loop which failed as seen in another post from PJ Allen.
e.g.
j = 7
FOR i = 0 TO 7
tmp4.j = tmp3.i
j=j-1
NEXT
However, sometimes you need to break it down to the simplest form like Zoot did. This is working but I have other minor issues to deal with (which I will try to work out before I ask for help).
I am writing code for the new 0832 Display boards and have it almost working but these boards use nibbles not bytes so it's a bit awkward: http://www.sureelectronics.net/goods.php?id=903
PS: Is there any advantage (e.g. significant speed difference or saving ram space, etc.) using Bean's assembly language routine as I am not familiar with this as much as SX/B?
Thanks again guys!
http://www.sxlist.com/techref/ubicom/lib/math/bit/revbits_sx.htm
regards peter
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (JonnyMac) : 5/22/2009 12:56:56 AM GMT