Shop OBEX P1 Docs P2 Docs Learn Events
First Steps — Parallax Forums

First Steps

UnsoundcodeUnsoundcode Posts: 1,532
edited 2007-01-23 17:45 in General Discussion
After getting to feel fairly comfortable with the BS2 and PBasic I want to spend some time on the SX/28. I don't have any particular project in mind but my question is what is the general opinion on basic v assembly, do you think learning assembly has benefits worth the time it takes to learn. Is assembly as good as basic, better than basic or a lot better than basic? All I have done with the SX so far is make a LED blink with the LED.src code provided, that wasn't too difficult [noparse]:o[/noparse]). I think I know which way to go but welcome any comments/input on language preference and anything that gives me·added insight on what the SX is capable of.

thanks in advance
Jeff T.

Comments

  • pjvpjv Posts: 1,903
    edited 2006-12-16 03:15
    Hi Jeff;

    Personally I have never owned a Basic Stamp of any sort, so I have no idea as to its ease of use. I happen to get involved with the SX in assembler, and that's all I really know. Although I had a go at SX/B, but found it somewhat limiting, and quickly gravitated back to my comfort zone - assembler.

    I'm interested in trying out the C language and hope that it will be available in stable form soon.

    I also hope that SX/B can be enhanced to make it multi tasking, thereby removing its biggest obstacle..... it could become a real rocket!

    I believe that assembler is only slightly more difficult than the other approaches, but for me at least, it takes much longer to write code. Once that is done however, it's performance will outshine anything else...... by a LONG shot.

    So it all depends on your particular bent, higher level languages for convenience, or assembler for performance.

    My view.

    Cheers,

    Peter (pjv)
  • JonnyMacJonnyMac Posts: 9,214
    edited 2006-12-16 04:28
    Having worked with SX/B for a long time I think it's fair to say that it lives somewhere between PBASIC (very full featured BASIC) and Assembly (blazing speed, do what you want, not as easy to code for beginners). I think it's a good balance of abilities. The cool thing is as you learn neat assembly tricks from gurus like Peter (pjv) you can incorporate them into you SX/B programs (SX/B supports Assembly code blocks). You may ultimately switch to pure Assembly, but you don't have to -- SX/B produces very nice code and if you structure your code like an Assembly programmer would, the results are fairly compact.

    Remember, SX/B compiles to straight assembly -- now, it will never be quite as fast as properly designed, hand-coded Assembly, but it will absolutely run circles around the same program running on a BASIC Stamp.
  • CCraigCCraig Posts: 163
    edited 2006-12-16 14:44
    As for me, working with the SX/B for a SHORT time, it really is a good teacher. For now, I spend most of my time on the Basic side. Alas, as it always happens, I am being pulled to the dark side. The training wheels will soon come off. Until then, I'm shifting gears back and forth.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2006-12-16 15:53
    Thank you all for your replies, when I see words like "real rocket" and "blazing speed" it inspires me and affirms what I am already thinking. I am just starting to work through Exploring the SX Microcontroller with Assembly and BASIC Programming , I am sure SX/B has a place especially if you need to put a simple program together quickly and Basic is more familiar to you, but initially I will don my "training wheels" and concentrate my efforts on assembly.

    Peter, you say C in stable form does that mean there is C in unstable form right now? I used to do a small amount of C programming as a hobby and would be interested if it were available for the SX.

    thanks

    Jeff T.
  • pjvpjv Posts: 1,903
    edited 2006-12-17 01:14
    Hi Jeff;

    I understand that Parallax has a "C" compiler deal in the works with CCS for some time now, and hopefully that will be out of Beta testing soon.

    It is of course not up to me to make predictions.... Parallax will surely do that in due course.

    Cheers,

    Peter (pjv)
  • LogicmanLogicman Posts: 4
    edited 2007-01-01 15:23
    Hey Jeff !!

    ··········· Guess who?· I have my· sx chip now and I am also interested in assembly language. Drop me an e-mail if you read this today.

    ··········· rickymcc@netzero.net.





    ·············································· Ricky
  • tommytommy Posts: 84
    edited 2007-01-22 23:46
    note: tommy discovered assembly language in the 80's using MS-DOS and then spent twelve years writing all sorts of things - now obsolete, of course... but I've "never looked back".
    to "unsoundcode":
    well, even the non-blazing speed is too fast to comprehend now-a-days --- let me add "pin-point accuracy" to the phenomenon called assembly language --- what you write is what the chip does ! ! ! --- nothing less, nothing extra.
    you say that you have made an LED blink - well if you can see the blinks, then you must have written code to make a "delay" of some sort - "wasted time" making the chip count to 2,000 or 20,004 --- and now instead of lighting a light, you might trigger another chip to sequence current to a stepper-motor, or to count the vibrations in your TV-remote's infrared signals...
    it's "pure" - this assembly language - and each small part is fairly simple, too. Your own little library of more complicated tasks will build rather quickly - and you will find satisfaction in "complete control" - that you know the purpose of every byte in the program. If your chip is mis-behaving --- you told it to do that - (and therefore you can fix it, too).
    Basic is too vauge -- maybe I can use my old basic stamp as some sort of memory device for a data-logger --- I "dropped" it after only one program when I then discovered the SX chips... and good ol' Assembly Language.

    tommy
  • Ken GraceyKen Gracey Posts: 7,403
    edited 2007-01-23 00:10
    Jeff T:

    The "Exploring the SX Microcontroller with Assembly and BASIC" is very old. That book was written for the first or second release of SX/B and won't give you the right introduction. Instead, use the SX/B Help File as your guide, as well as any SX/B examples you draw from the Parallax web site.

    In short time, Jon Williams' book "Practical SX/B" will be available. John Kauffman's SX/B book is also underway, each with a different approach. You'll learn about those resources on this forum first, of course.

    Ken Gracey
    Parallax, Inc.
  • Keith MKeith M Posts: 102
    edited 2007-01-23 02:06
    Unsoundcode said...
    opinion on basic v assembly, do you think learning assembly has benefits worth the time it takes to learn. Is assembly as good as basic, better than basic or a lot better than basic?

    Jeff,

    Tough questions here.

    Yes, learning assembly will definitely help you in the microcontroller world. These type of projects are hardware related and can require tight timings, especially when communicating to outside chips and devices. Because you know each instruction takes a certain number of cycles(usually 1 instruction = 1 cycle = 20ns at 50mhz) it's easy to tell exactly when something is going to happen. Assembly is about as close to the hardware as you can get and so it is a low-level language. Low-level languages give you the power to do whatever you want, but comes at a price of complexity, and things that you might take for granted in a higher-level language simply aren't there in assembly. Assembly instructions are usually the most basic, the most atomic operations you can perform.

    Basic on the SX I've found to be really easy. Quick to pickup. It's not a "full-fledged" version of basic, unlike what you might have played with on a PC. There are some commands that have limited flexibility and options, but newer additions like 16-bit variables are nice. It has some nice features like I2C support, one wire stuff, a UART that runs at a respectable speed(although I'd love to see this work even faster) As far as "rapid application development", basic is great for throwing together a working program quickly.

    For my purposes (hobby projects etc), I use a mixture of assembly and basic on the SX. For anything with critical timing, I use assembly. In my current project, I have my ISR written in assembly, because it's firing pretty frequently, and I wanted to get in and get out. For my memory communication, I'm doing everything in assembly. I *was* using assembly for a bit-banging UART, but found that I had a minor timing glitch (related to MOVB taking a different number of cycles based on contents of the source bit), and so the (although maybe temporary) fix was actually to go to known-good working code, the basic UART.


    Answer? Use the right tool for the job.

    HTH,

    Keith
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-01-23 17:45
    Thanks for the input guys, my progress is good but Im at a point where it takes me several re-reads of a chapter to grasp it.

    Tommy, I made that led blink with copied code, but·I do·fully understand it now. Like you say I understand every byte, Im not going to give up it's just going to take a long time.

    Ken, Im hungry for good books and have already been recommended to look at some of Guenther's works.

    Keith, I'm purposely staying away from the SX basic for now to avoid slipping into the easy way out, once I feel I am somewhere near competent I will then look at the basic, right now I will concentrate on asm. ISR's and Uart's I see are important, but so difficult to understand.

    Thanks again for the support

    Jeff T.
Sign In or Register to comment.