Shop OBEX P1 Docs P2 Docs Learn Events
Problem with Toggle Statement — Parallax Forums

Problem with Toggle Statement

George-ILMGeorge-ILM Posts: 9
edited 2008-10-20 05:34 in General Discussion
I am new to the SX and to SX/B and am unsure what might be the problem with the "TOGGLE reverseDirection" statement at line 100 in the attached SX/B source code.· I have SX/B 1.51.03 and SX Key 3.92.h beta.

When I compile the source code the resulting assembly listing shows an error at "Line 288, Error 1, Pass 2"
(XOR reverseDirection,#%00000100 ;····· TOGGLE reverseDirection).

The variable 'reverseDirection' is used in an earlier statement, seemingly without problem.· Also there is an earlier TOGGLE statement resulting in an apparently valid XOR statement.

I would appreciate any insight into this problem.

-- George

Comments

  • CapdiamontCapdiamont Posts: 218
    edited 2008-10-20 04:16
    I've had problems with that too in the past. The other way to do that is

    reverseDirection = NOT reverseDirection

    Edit: replaced your code with above, and it works fine, or at lease compiles.

    Post Edited (Capdiamont) : 10/20/2008 4:23:14 AM GMT
  • George-ILMGeorge-ILM Posts: 9
    edited 2008-10-20 04:26
    Well, it is comforting to know that I am not the only one who has encountered the problem.· The generated assembly code looks reasonable (to this newbie).· It is unclear to me why the XOR statement is flagged as a problem.

    I see that the SX/B compiler software is several years old.· Is it still being maintained?
  • CapdiamontCapdiamont Posts: 218
    edited 2008-10-20 04:44
    Should have 2.0 release soon.
  • mojorizingmojorizing Posts: 249
    edited 2008-10-20 05:34
    George,
    XOR is looking for a byte.· If you substitute the following in your variables declaration, it'll compile.· Notice now·the XOR is with "DirectionByte" in the list file.
    ' ---------------------------------------------------------------------------------------
    ' Variables
    ' ---------------------------------------------------------------------------------------
    powerLevel VAR BYTE
    powerUnits VAR BYTE
    DirectionByte VAR BYTE
    reverseButDwn  VAR DirectionByte.0
    powerButDwn  VAR DirectionByte.1
    reverseDirection VAR DirectionByte.2
    
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Bad spellers of the world untie!
Sign In or Register to comment.