Shop OBEX P1 Docs P2 Docs Learn Events
Convert my old .bsx-files to .asm or .hex-files? — Parallax Forums

Convert my old .bsx-files to .asm or .hex-files?

J.WeJ.We Posts: 15
edited 2013-08-16 19:58 in BASIC Stamp
Hi,

Can I use the Basic Stamp editor to create a program, compile and from the .bsx-file see the .ASM-file or .HEX-file?

Or is this converting done in the hardware (I use a BS2sx)?

I want to use my old .bsx-files convert them to .ASM or .HEX and program them into another microprocessor (PIC)…

Do you have any suggestions?

Thanks in advance!

(I have also posted this subject to the STAMP in Class forum)

Regards
jw

Comments

  • ForrestForrest Posts: 1,341
    edited 2007-01-19 11:33
    The Basic Stamps can only run Basic, not assembly/machine language progams. If you want to switch to a PIC processor you'll need to convert your programs to the other version of Basic that runs on those processors and get a Basic compiler (which can cost up to $300) and a programmer. I'd look at the inexpensive Parallax SX processor (which is a fast version of a PIC processor), the SX Blitz programmer and the free SX/B compiler.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-01-19 11:45
    JW -

    Just to add a bit more information to this thread, PBASIC is an interpretive languafe, not a compiled language. There is an intermediate code-form, but it is neither ASM, HEX, nor machine code. The intermediate code is often known as "tokens" and these tokens are first fetched by the PBASIC Interpreter, then interpreted, and finally executed via interpretation.

    Moreover, unless you made some special provisions, one could not even take the intermediate code designed to run on one Stamp model, and load it and run it on another Stamp model. It would have to pass back through the PBASIC IDE in source languiage form, with the new target processor identified.

    Regards,

    Bruce Bates
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-01-19 14:41
    Other vendors do make compilers that do this. And the boards you'll need to plug the 'native' PIC into in order to get it to work, and give yourself a programming platform for it. But the price is around $350 for the compiler, and you WILL need at least one board to use for programming.

    And even then, you'll have to 'tweak' your PBasic code to make the other compiler happy. But it can be done. This makes sense if you're delivering to your customer more than 10 systems, and especially if you're making your own boards, as the price of the native PIC is much less than a BS2.

    But the BS2 is still one of the best prototyping and 'try-out' environments around.
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-01-19 14:47
    Oh, and the way the BS2 works is --

    On the BS2 is a PIC chip (different flavors of BS2 use different chips -- PIC16C57 is the 'plain' BS2 pic chip). In this chip is programmed the 'run-time' routines, which are Parallax proprietary, and not user accessible.

    In the IDE, you write your program using PBasic. The IDE then compiles each keyword into 'tokens' (an integer, basically). The IDE then downloads these tokens to the on-BS2 eeprom chip. The BS2 runtime, when running, then fetches each token from the eeprom. Each 'token' is then used by the run-time on the PIC to select and run a small piece of code which implements the functionality for that keyword.

    So you see, your code is not complete UNTIL you download it into some BS2 chip, because the run-time routines are never included with your code. Now, the way compiler vendors work, is they supply a linkable library of their run-time routines so you CAN have a complete .hex or .bin file to download to a completely empty PIC.
  • Riley GunnRiley Gunn Posts: 1
    edited 2013-08-16 15:38
    What if I flash a PIC16f57 (= to a BS2 stamp) with the BASIC Stamp compiler then read it with say an EasyPic7 and MicroProg Suite, would it be able to generate a hex code then? I know that I am able to read the hex file from a PIC with the EasyPic7 and MicroProg Suite. In other words what I am asking is after the BASIC Stamp compiler flashes the chip will it be a hex file that is embedded in it?
  • Mike GreenMike Green Posts: 23,101
    edited 2013-08-16 19:58
    Sort of. First of all, it's not a BASIC Stamp compiler. You're talking about using a PICBasic compiler which is not quite the same, but close. The PICBasic compiler produces assembly source code which it assembles to produce essentially a hex file. There are several hex file formats and I think the assembler can produce any of several of these. This hex file is what it uses to download the program to the PIC's flash memory (using a utility program to do the downloading). The PIC only sees a sequence of 8-bit values sent one bit at a time. These 8-bit values are what's stored in the PIC's memory.

    The BASIC Stamp compiler uses a completely different file format for its compiled interpreter byte codes. You can't flash a PIC16F57 with the BASIC Stamp compiler. The Stamp module has a downloading program built into it which accepts the file from the PC and loads it into a separate 2K byte EEPROM on the Stamp module. The PIC16F57's flash memory contains the PBasic interpreter and the downloading program and can't be changed except by Parallax.
Sign In or Register to comment.