Setting a single bit in Spin
Rumple
Posts: 38
I can't believe I've never tried to do this before. What's the best way to set and reset a single bit of a long in Spin? I've always assumed it was "someregister[0]~~ ",since "outa[0]~~" works, but apparently that's not it.
Something with "|<" in it maybe?
Something with "|<" in it maybe?
Comments
To "or" one mask to another (oring enableMask on to activeMask)
To turn off these same bits (same function as "andn" in PASM):
Thanks to my fellow forum members for this useful stuff.
To clear a bit use this: It will decode the bit, which creates a value with only that bit high, invert it, which makes all bits high except the one you are clearing, then AND the result into the variable, effectively clearing that bit within the variable.
David Carrier
Parallax Inc.
Just copy the long you want to work with to DIRB and then Spin will let you do dirb[SomeBit]:=1 and things like that...
Also, that's brilliant, Rayman.
H
If you want to read a group, set bitpos to the LSB value and change the & %1 to something that fits your group; for a nibble it would be & %1111.
For example, you can set bits 4 through 9 to a value like this: INB[4..9]:=value
You can even set them backwards like this: INB[9..4]:=value
I am just finishing up the beginners book and I can add this great stuff to it.
Just in time.
H