Shop OBEX P1 Docs P2 Docs Learn Events
SX starting place, any thoughts? — Parallax Forums

SX starting place, any thoughts?

GRCGRC Posts: 22
edited 2005-07-05 13:26 in General Discussion
Hello All.
I been researching the SX and its features.· The problem is I haven't learned assembly
yet.· I see the SX can now be programmed in basic, but at the·price·of non optimizing.
I'd like you hear personal view points of poeple that use basic to program thier SXs.
I have downloaded the "Beginning Assembly Language for the SX Microcontroller", and
read a good deal of it so far. Anyone have·suggestions on learning assembly with the SX.
Is easier than it seems?

Thanks in advance
Gordon

·

Comments

  • pjvpjv Posts: 1,903
    edited 2005-07-03 05:55
    Hi Gordon;

    Learning assembly in the SX is a piece of cake.

    O . N . E . . B . Y . T . E . . A . T . . A . . T . I . M . E

    It takes logical thinking, painstaking detail, LOTS of time and LOTS of experimentation. But once you get proficient........ there is a lot you can accomplish with fast processor such as the SX.

    Cheers,

    Peter (pjv)
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-03 13:44
    Gordon,

    Don't be disuaded by that term "non optimizing."· Parallax happens to be very honest in its approach, most companies would never mention that about the same kind of compiler.· But let me show you that this is NOT a problem, and gets you into the SX very quickly.· And can help you learn assembly as you can see the compiled output (you can even modify it to experiment).

    I'm part of the EFX group and we have some new serial modules coming that use the SX and are completely programmed in SX/B.· Yes, we use our own tools to develop products.· The devices we're creating follow the Parallax AppMod protocol, and generally want to wait on a specific header, for example, something like this:

    ·· "!EFX"

    If we code for that header like this:

    Main:
    ··SERIN Sio, Baud, char
    · IF char <> "!" THEN Main
    ··SERIN Sio, Baud, char
    · IF char <> "E" THEN Main
    ··SERIN Sio, Baud, char
    · IF char <> "F" THEN Main
    ··SERIN Sio, Baud, char
    · IF char <> "X" THEN Main

    ... it works, but each instance of SERIN uses of a bit of code space.· So we can hand-optimize (which assembly programmers do all the time) by putting SERIN into a subroutine:

    RXBYTE:
    · SERIN Sio, Baud, temp1
    · RETURN temp1

    Now the SERIN code is compiled in just one place.· As of version 1.3, subroutines can behave like functions, so the header block above would be recoded as:

    Main:
    ··char = RXBYTE
    · IF char <> "!" THEN Main
    ··char = RXBYTE
    · IF char <> "E" THEN Main
    ··char = RXBYTE
    · IF char <> "F" THEN Main
    ··char = RXBYTE
    · IF char <> "X" THEN Main

    Since -- other than the PBASIC-like commands -- SX/B is a light version of BASIC, most lines of code translate 1-to-1 to assembly.· SX/B is free ... so it does't hurt to give it a try and mix in assembly as you get more comfortable with it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Keith MKeith M Posts: 102
    edited 2005-07-03 15:29
    GRC said...
    Hello All.
    I been researching the SX and its features.· The problem is I haven't learned assembly
    yet.· I see the SX can now be programmed in basic, but at the·price·of non optimizing.
    I'd like you hear personal view points of poeple that use basic to program thier SXs.
    Hi Gordon.
    I've started with playing with the SX about 3 or 4 months ago, so I'm still a novice, so you'll have to take that into consideration with my comments.
    I've found SX/B to be remarkedly easy, and powerful.· I was writing little sample programs with leds, switches, etc on the same day I got my SX.· SX/B is really intuitive, like Basic's should be --- if you have any experience with any programming language, the learning curve is zero.· And as far as "optimizing" goes, SX/B is translated to assembly, and then assembled.· It's not interpreted like it is on other platforms like PCs, etc.· Normally that interpretation is what is slow, requires lots of memory(relatively speaking), etc.
    There *are* penalities for using SX/B, in that startup code, entry and exit to the Interrupt Service Routines, etc have these mandatory code segments which add possibly unnecessary overhead to your code.· Now in ASM, you may have to very much have to have similar code, but obviously you have a lot finer grain control over what gets done in those routines.
    SX/B is still in its infancy, so it's not really polished or perfected yet.· But there appear to be regular updates, and I'm sure the problems, lack of features, etc·there are will be rectified.
    As far as learning ASM, I know just enough to be dangerous.· I have the theory down, have had college classes on the subject, etc.· But I have very little practical experience.
    I think you'll find the bulk of the community support, books, published projects etc·is going to be in ASM.· But I think it really depends on what your purpose is for the SX.· If you have a small, non-demanding hobby project, I think SX/B is just fine.
    I plan on learning SX ASM in the near future.· But sure, there is a high entrance cost.· Most will tell you that it's worth it.
    And as Jon mentioned, you can get an assembly-output for your SX/B code, so this makes learning ASM even easier.....
    Hope this helps,
    Keith
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-03 16:03
    Any *penalties* incurred for the start-up code or for saving context before entering the interrupt (and restoring it after) are at the user's discretion.· SX/B allows a NOSTARTUP option for the PROGRAM directive, and INTERRUPT instruction has NOPRESERVE and NOCODE options.

    The point of SX/B was to make it easy for new programmers to get started with the SX, but we also wanted advanced programmers to have their way (while simplifying their life a bit with BASIC).· We think we've done this, and it's probably going to remain as is for some time as we haven't had any requests for additional features (most of the updates we've made the last few months have come from our own use as a tool).

    On an intersting note concerning context saving for interrupts, the way SX/B has been designed makes BASIC reentrant (though you need to be careful with this).· I think a great example of this is how Bean made a PWM module that takes serial commands.· He had to do a bit of work to ensure the interrupt always ran the same number of cycles, but by doing that he was able to use the SERIN instruction (with an adjusted baud rate) and it can be interrupted to process the PWM outputs -- that saved him the trouble of adding a software·UART to the already-busy interrupt routine. ·I think that's pretty cool, and demonstrates just how capable SX/B is.·

    And you can't beat the price! tongue.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Keith MKeith M Posts: 102
    edited 2005-07-03 17:02
    Jon Williams (Parallax) said...

    We think we've done this, and it's probably going to remain as is for some time as we haven't had any requests for additional features (most of the updates we've made the last few months have come from our own use as a tool)

    Hi Jon.

    I assumed you guys had a long list of requests and were filling them as time allowed!· There's been at least a few times that I said, "darn, I wish I could do this....."

    IF.....THEN.....ELSEIF...ENDIF was really needed -- glad to see that one go in! Especially because you can have blocks of code, instead of just a label.

    One that springs to mind quickly is the ability to have multiple conditions on the same line of code for an IF statement, in C it would be something like

    if ((variablea == 5) && (variableb < 57)) {//do something here}

    The code gets awkward when you need a couple IFs in a row.· Plus, it's hard to read.

    Also, a lot of your operators require VALUES, and won't take variables instead.

    There are also a couple places in the Online Help where the author says, "this works just like the assembly instruction xxx except that....." etc.· Especially because its basic, you should never assume any knowledge of assembly --- if the users knew assembly, they wouldn't be using basic.

    Keith
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-03 17:11
    Thanks for the feedback, Keith. I think we probably won't add multiple conditions on one line because that would make the assembly output·a big mess, and the FIRST goal of SX/B is to help users move from BASIC to SX assembly. If one wants full features like multiple conditions there are professional compilers available for that.

    Since I'm responsible for the help file, I will fix that comparisons to assembly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Keith MKeith M Posts: 102
    edited 2005-07-03 17:36
    Hi Jon,

    I·sort of figured that was case with the fact that you are doing 1-1 translations, and that any multiple statements would start hosing up the assembly.

    Overall though, the idea behind translating basic to assembly is excellent.· Great idea. Kudos to whoever decided to take that approach!

    Thanks.

    Keith
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-03 17:43
    Thank the boss (Ken G) -- he wanted to get people as excited about the SX as we are and then let us put together a team to make the SX/B compiler happen. And you've seen his nutty prices on proto boards...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • GRCGRC Posts: 22
    edited 2005-07-05 13:26
    Hi All.

    Thank you for great replies.·Its definitely helpful to hear other peoples

    views on this beore I buy.



    Once again, Thank you for your input

    Gordon
Sign In or Register to comment.