Shop OBEX P1 Docs P2 Docs Learn Events
Problem with SX/B Compiler — Parallax Forums

Problem with SX/B Compiler

Fe2o3FishFe2o3Fish Posts: 170
edited 2007-11-01 16:54 in General Discussion
A simple little program as follows:
001 DEVICE          SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
002 FREQ              4_000_000
003 ID                  "Foo"
004
005 Program        Start
006
007 LED1    VAR    RB.0
008
009 FOO    VAR    BYTE
010
011 Start:
012   FOO = 165
013   RANDOM FOO
014
015 Main:
016   LED1 = FOO & 1
017   PAUSE 500                    ' delay
018   RANDOM FOO
019   GOTO Main                    ' repeat forever
020
021  END



Compiling with SX-Key v3.2.3 (the latest version, under Windows XP) comes up
with this error message:
foo.SXB(54)Line 16, Error 16, Pass 1: UNKNOWN COMMAND "LET".

Oh really??? I thought it might be the LE in LED1 bringing up the "LET"
so I changed all LED1's to LAD1 and I get the same error message. <sigh>

The SX/B compiler seems to be a little loose on compiling as I've had
other strange things happen like undefined variables being permitted by the
compiler only to have the assembler burp on an undefined symbol called <TEMP>
(which I don't use in my code). I'll report them when I find 'em as I start my
adventure into SX/B coding.

What's up?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Rusty-
--
Rusty Haddock = AE5AE = rusty@fe2o3.lonestar.org
**Out yonder in the Van Alstyne (TX) Metropolitan Area**
Microsoft is to software what McDonalds is to gourmet cooking

Comments

  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-11-01 14:40
    You're attempting to move a byte (result of FOO & 1) into a bit -- can't do it (PBASIC masks this by moving bit zero of the result which is probably what you want). Logically, your program could be:

    Led1 = foo.0

    ... because any bit ANDed with 1 will remain unchanged, therefore you can simply copy the target bit to the output LED.
  • BeanBean Posts: 8,129
    edited 2007-11-01 14:57
    Jon is correct. You cannot assign a larger variable type to a smaller variable type.

    Please DO post any errors you get with the compiler. We will try to explain and/or correct them.

    Bean.

    Post Edited By Moderator (Chris Savage (Parallax)) : 11/2/2007 3:46:08 PM GMT
  • Fe2o3FishFe2o3Fish Posts: 170
    edited 2007-11-01 15:42
    Okey dokey. When I get home tonight I'll dig up the (I now know INCORRECT code)
    that generated the message about an undefined symbol, <TEMP>.

    Still, that error message about an unknown command "LET" could
    sure be a tad more informative. :-\

    Let me take this a little further -- how would I assign the low three bits of 'foo' to the
    low three bits of an I/O port, say RB?

    Thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Rusty-
    --
    Rusty Haddock = AE5AE = rusty@fe2o3.lonestar.org
    **Out yonder in the Van Alstyne (TX) Metropolitan Area**
    Microsoft is to software what McDonalds is to gourmet cooking

    Post Edited (Fe2o3Fish) : 11/1/2007 3:47:08 PM GMT
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-11-01 15:49
    Well, you could do this

    RB = foo & %00000111

    or, if you didn't want to disturb the other bits of RB, then:

    RB.0 = foo.0
    RB.1 = foo.1
    RB.2 = foo.2

    or, here's another way:

    tmpB1 = foo & %00000111
    RB = RB & %11111000
    RB = RB | tmpB1
  • Fe2o3FishFe2o3Fish Posts: 170
    edited 2007-11-01 16:14
    OK, those certainly make sense. Wuz thinkin' that there might be
    a SX/B-specific syntax for doing the three bits.

    (note to self: think RISC when doing SX/B programming)

    Thanks John^H^Hn! smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Rusty-
    --
    Rusty Haddock = AE5AE = rusty@fe2o3.lonestar.org
    **Out yonder in the Van Alstyne (TX) Metropolitan Area**
    Microsoft is to software what McDonalds is to gourmet cooking
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-11-01 16:54
    Yes, SX/B is very close to the machine, and if you think that way you will be rewarded with high performance and quick development cycles.
Sign In or Register to comment.