Single Bit Access
crgwbr
Posts: 614
Is there any way to set a specific bit of a variable to a 1 or 0? For example, if byte x == %00000000, I want to be able to set each individual bit separately from the others. Can I do this in SPIN? I haven't seen anything in the manual about it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -
"If Python is executable pseudocode, then perl is executable line noise."
"The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."
"My software never has bugs. It just develops random features."
"Windows isn't a virus, viruses do something."
"Programmers are tools for converting caffeine into code."
"Enter any 11-digit prime number to continue."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -
"If Python is executable pseudocode, then perl is executable line noise."
"The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."
"My software never has bugs. It just develops random features."
"Windows isn't a virus, viruses do something."
"Programmers are tools for converting caffeine into code."
"Enter any 11-digit prime number to continue."
Comments
var &= !(|< bit)
to set:
var |= |< bit
where bit is the bit number (0,1,2,3,...,30,31)
to test:
var AND |< bit
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -
"If Python is executable pseudocode, then perl is executable line noise."
"The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."
"My software never has bugs. It just develops random features."
"Windows isn't a virus, viruses do something."
"Programmers are tools for converting caffeine into code."
"Enter any 11-digit prime number to continue."