Shop OBEX P1 Docs P2 Docs Learn Events
Loading code and executing it — Parallax Forums

Loading code and executing it

Aaron193Aaron193 Posts: 27
edited 2009-08-01 02:29 in Propeller 1
Hi, everyone--

I'm having a load of trouble with loading code from an external source and executing it. My goal is this: I have a separate program compiled into a binary or other form that is loaded into the RAM during bootup. During the main program, I want a cog to find that code and execute it as if it was part of the main program, much like the PropDos "Spin" command does. How should I go about doing this?

For instance: I have a "pub" function called echo. I want to move this function to a separate file and load it onto EEPROM so it can be loaded into the Propeller's RAM during runtime and then executed as if it was part of the original code. Is this possible?

Aaron.

Comments

  • jazzedjazzed Posts: 11,803
    edited 2009-07-27 04:14
    Aaron193 said...
    For instance: I have a "pub" function called echo. I want to move this function to a separate file and load it onto EEPROM so it can be loaded into the Propeller's RAM during runtime and then executed as if it was part of the original code. Is this possible?

    Aaron.

    Short Answer: No. It is not a feature of any currently available tools.

    Long Answer: Yes.
    But it's a lot of work and something I actually started work on last week smile.gif.
    This idea is the basis of my "BigSpin" VMM project which is slowly coming together.
    Hacking the function or the interpreter so that all references to object variables are correct is tough so far.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • Aaron193Aaron193 Posts: 27
    edited 2009-07-30 20:59
    I understand there is a built-in Spin interpreter on the Propeller. Is there an easy way to access that while in a program? For instance: I'm trying to make a UNIX system using the Propeller. I would eventually like to be able to write programs on it using C. Just for starters, assuming I have a filesystem of sorts containing text files with Spin code in them, is there a way I can execute those files as Spin code?
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-07-31 01:38
    Currently, only to completely reload the prop code from SD. See PropDos in one of my signature links for code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, RamBlade, TwinBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index) ZiCog (Z80), MoCog (6809)
    · Search the Propeller forums (via Google)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • BradCBradC Posts: 2,601
    edited 2009-07-31 01:44
    Aaron193 said...
    I understand there is a built-in Spin interpreter on the Propeller. Is there an easy way to access that while in a program? For instance: I'm trying to make a UNIX system using the Propeller. I would eventually like to be able to write programs on it using C. Just for starters, assuming I have a filesystem of sorts containing text files with Spin code in them, is there a way I can execute those files as Spin code?

    http://forums.parallax.com/showthread.php?p=738145

    Yep, you can. The above link shows how you can load a complete .binary image anywhere in available ram and start it in a separate cog while keeping your original code running.

    It's not elegant by any stretch of the imagination and you'll need to ensure you keep your memory spaces separated properly (or get really funky and use some designated memory for IPC), but it certainly can be done easily.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <This space for rent>
  • Aaron193Aaron193 Posts: 27
    edited 2009-08-01 02:29
    Grand...one last thing: is there any documentation as to how SPIN is compiled? My grandiose idea (which will probably fail) is to make a C compiler within the program/propeller OS that compiles into Propeller-readable binaries. How hard is this?
Sign In or Register to comment.