I know this a very boring code question, but I need to sample the binary version of some variables, and store those bits in separate variables to later be reconstructed into an integer.
For example: Say I am storing the integer 25 in a variable, which would be 00011001 in 8-bit binary. (I don't know exactly what format Propeller chips store the values of variable as, so I am using 8-bit as an example) I want to sample each bit, and store them in separate variables. So, here, I would be converting the original variable (equal to 25 in this example) into an eight variable array: Var[0..2] := 0, Var[3..4] := 1, Var[5..6] := 0, and Var := 1. Like I said, I want to deconstruct the original variable's value, and store it as a series of binary values in a series of other variables. A different process will reconstruct this series of binary values back into a binary representation of an integer, which will be stored in separate variable.
Is there a Spin language command that will allow me to sample every bit in a looped command, one right after another? That would be hella sweet. If I need to heavily process the original variable, so be it. Obviously, the latter scenario would be less desirable, but life doesn't always go the way we would like.
I really don't want to have to use a zillion operators just to so something that any fool's eye could do. After all, basically, in the example, all the code needs to do is remember the we have got three zeros in a row, followed by two ones, and then two more zeros, and a one. Very simple concept. They human brain is so good at it, but did anyone build that feature into the Spin language?
And then the reconstruction would be the reverse. Simple concept again, but is there an easy way to do it in Spin?
I am deliberately leaving out what the device is for. This is because, I don't want to use some one else's object that I don't understand. Someday, the device might outgrow the capabilities of the Propeller, and, on that sad day, I will need to migrate to more powerful hardware. I have already used about half of the memory on one of the P1's I am using, and there are lots more features that I want to add. If I write the code, I can keep it as compact as possible. And I can easily rewrite it in another language on that sad day when I have to say goodby to the Prop chip (and Spin language).
I have a viable (and more compact) alternative to deconstructing/reconstructing integers in their binary form, but it will execute a certain process more slowly.
So, help would be appreciated! I was assuming there would be a tutorial on this sort of thing, but I can't find it anywhere!