View Full Version : stupid bool question

03-16-2009, 04:10 AM
Id there no bool type variable in spin?
smallest is just byte?

I·just want to do myVar:=!myVar and toggle between 0-1 to keep as a flag for something.

obviously with a byte it will toggle 0 and 255

whats the best / efficiant way to do that for a single flag?

thanks Jesse

Mike Green
03-16-2009, 04:19 AM
You're right, there's no Boolean variable in Spin. False is zero and true is non-zero with the name TRUE equivalent to all one bits. Spin does have logical bit operators like !, &, |, ^ which can be used to do bit flags. It also has the bit mask operator |< and shifts of all sorts. In terms of storage, there are only bytes for small units. The special registers can be bit addressed and the "B" set of registers are not implemented in hardware although the names INB, OUTB, DIRB do exist and can be bit addressed. The locations themselves are in cog memory. Each cog has its own copy.

03-16-2009, 04:28 AM
Thanks mike.

Chris Savage
03-17-2009, 01:44 AM
I prefer to use a BYTE variable to store multiple bit values. Perhaps this could work for you as well. Take care.

Chris Savage
Parallax Engineering