Assembly and C
varun
Posts: 13
Hi
I have Basic Stamp 2 and the BoE. I have done experiments on it using PBASIC.
I am very interested in being able to program it in assembly language and C. How can I do it? I can try to get a free compiler for this, but how do I download the machine code in the Basic Stamp on the BoE?
Please help me on this. Is there a conveniant integrated environment to program, assemble/compile and download Assembly/C code on BS2 on BOE.
Thanks
Varun
I have Basic Stamp 2 and the BoE. I have done experiments on it using PBASIC.
I am very interested in being able to program it in assembly language and C. How can I do it? I can try to get a free compiler for this, but how do I download the machine code in the Basic Stamp on the BoE?
Please help me on this. Is there a conveniant integrated environment to program, assemble/compile and download Assembly/C code on BS2 on BOE.
Thanks
Varun
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Now, if you go the PIC native route, there are a few 'C' compilers -- but the development environment is going to cost on the order of $500. And the Parallax SX/B environment is VERY nice -- mostly assembly code, and a little Basic, but runs at 50 MIPS. Yowza.
Thanks for the reply.
I am interested to know why has the PBASIC engine put on the PIC chip. Couldn't there be an interpreter which would convert PBASIC code into machine code on the PC. Then we download the machine code on the PIC microcontroller?
Kindly let me know.
Varun
The Stamp was made for ease of use.
why do something like that when there are already plenty of other options out there like that?
microchip.com
atmel.com
zilog.com
the list goes on...
As well there is also the SX which is supported by Parallax and you can get Assembly, C, Basic, ect. compilers which in turn could download machine code to the device.
Its there really for simplicity and ease of use. Its much easier as a beginner to start tinkering with the stamp then it is to start messing around with the others.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
DTQ
If you have a need for speed, you can use what you've learned with the BASIC Stamp and apply it to the SX using our free SX/B compiler.· It's very PBASIC like, and allows you to mix in assembly language (see my column in the June issue of Nuts & Volts magazine for an example of that: I'm using assembly do buffer serial input while the foreground BASIC program processes data from the serial buffer).· Using SX/B is easy, lets you do really neat things, and if you decide you want to use C, there are in fact companies that sell C compilers for the SX so you'd already have the tools.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks for your reply. I understand and appreciate the ease of using Basic Stamp. There are no two opinions about it.
However I am still not sure if my question has been answered. The hardware implementation with basic stamp must be converting basic stamp tokens to machine language code. Cant the same be done in software.... convert the pbasic code in machine language and download in the memory of PIC?
You talk about the quirks in compiler, but I am not sure if you have done it hardware, it surely could be done in software without many issues.
Kindly let me know.
Varun
Yes, there are compilers that will convert PBASIC-like languages to straight assembly code. We don't happen to make or sell any of those products (SX/B is close to PBASIC, and is free).
Here's the deal with my "quirks" comment: The PBASIC "engine" has been developed and optimized for a very specific set of microcontrollers; all the grunt work is done and there is not way to cause things to go wrong at the machine level (that doesn't stop you from making programming errors in PBASIC). But now go to Microchip's web site and see how many PIC variants they have ... a GOZILLIAN (that's an actual number, Forrest Gump uses it). It becomes extraordinarily tricky for compiler vendors to keep up with all those flavors, and very frequently a compiler user will try to compile code for one variant and run it in another and then ... kaboom. That's not an issue with PBASIC -- it runs on the micros we designed it for. Same with SX/B; a very limited target set.
In the end, you cannot program a BASIC Stamp in any language except PBASIC. That said, there is at least one company that makes a BASIC Stamp like module that does compile code to assembly for download. I've never used so I cannot comment beyond that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks for the reply. Sorry to respond late. It is indeed interesting to understand about all this.
Parallax's approach is innovative and interesting. I am more curious!! For instance, BS2 uses·a PIC16C57 as the interpreter (I see it as PBASIC2 on the Parallax site). Now, if I get it right, this IC is different from the PIC16C57 as sold by Microchip, since the PBASIC2 IC has a basic stamp engine aswell. Does this mean that parallax has redesigned PIC16C57·at ASIC design·level to include a PBASIC engine? Or is it that there is some software in the memory·of parallax's PIC16C57 (PBASIC2), which turns PBASIC code into assembly?
I will like to read documentation on this to understand the situation better. Any pointers will be useful.
Thanks
Varun
varun.aggarwal@gmail.com
When you use the Parallax IDE to compile your code, it compiles your code into PBasic Tokens, and using a run-time routine on the PIC16C57 (part of the PBASIC2 runtine) the PIC gets the tokens and puts them into the EEPROM.
Then when you select 'Run', the PIC reads the tokens out of EEPROM and 'executes' them -- in other words, lets the tokens select PIC code from the run-time library, programmed into the PIC.
So, the assembly code does reside in the PIC. There's a run-time engine set of code in the PIC that knows how to read the external eeprom and select which assembly code to run in the PIC. This has advantages in that a single integer from the EEPROM can cause execution of quite a lot of assembly code inside the PIC.
Now, before you ask, you should know that the PBASIC2 code is VERY Parallax proprietary. You can't read it out of the PIC, and even if you got a copy of the source the Parallax lawyers would be quickly asking for it back. This is Parallax's bread and butter we are talking about here. They are quite understandably very careful about what they say about this situation.
I personally don't work for Parallax, and the above stuff I've written is pretty generic for any run-time engine based application. It's the specific implementation that Parallax has done that provides the reliability and robustness (and simplicity, for that matter). And I can't say more than that, because I don't know any more than that.