DCD equivalent in SX/B or a way to access each bit in a loop?
In BS2, there is a command DCD which returns the highest bit position of 1 in a Byte.
I don't think there is a equivalent in SX/B, but what is a clever way of doing this?
e.g. for %00101111, I want to output %00100000
I tried the below code:
a VAR Byte
b VAR Byte
idx VAR Byte
Main:
··a = %01110000
· FOR idx = 7 to 0
··· b = a.idx
··· LEDs = b
· NEXT·
· GOTO Main
The above code will not compile because of a.idx is invalid.·
Is there a way to sequentially access each bit of a byte variable?
·
I don't think there is a equivalent in SX/B, but what is a clever way of doing this?
e.g. for %00101111, I want to output %00100000
I tried the below code:
a VAR Byte
b VAR Byte
idx VAR Byte
Main:
··a = %01110000
· FOR idx = 7 to 0
··· b = a.idx
··· LEDs = b
· NEXT·
· GOTO Main
The above code will not compile because of a.idx is invalid.·
Is there a way to sequentially access each bit of a byte variable?
·
Comments
Edit: 12/24/2008: I had a project that required an NCD function so I went back a looked at my code again -- here are better versions of both.
Post Edited (JonnyMac) : 12/24/2008 11:32:13 PM GMT