Shop OBEX P1 Docs P2 Docs Learn Events
stupid bool question — Parallax Forums

stupid bool question

s2jesses2jesse Posts: 62
edited 2009-03-16 18:44 in Propeller 1
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

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-15 21:19
    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.
  • s2jesses2jesse Posts: 62
    edited 2009-03-15 21:28
    Thanks mike.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-03-16 18:44
    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
Sign In or Register to comment.