Shop OBEX P1 Docs P2 Docs Learn Events
is there any way to limit what range of memory spin runs in? — Parallax Forums

is there any way to limit what range of memory spin runs in?

Bill HenningBill Henning Posts: 6,445
edited 2009-03-18 17:41 in Propeller 1
I realize I may need to use BSC instead of the propeller tool... but I've been working on something potentially interesting, and it would be VERY handy to be able to support running spin programs within a memory region I specify, and having some means of setting up a spin compiler to compile for that address range.

For example, let's say I wanted to use only $2000-$3FFF for spin; I'd like to do something like:

compile mytopobj.spin -m2000-3fff

and end up with a mytopobj.bin, that I could load from an SD card into memory starting at $2000; then I assume I could start either the rom spin interpreter, or a hacked ram cog version on it.

Any thoughts?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com - a new blog about microcontrollers

Comments

  • BradCBradC Posts: 2,601
    edited 2009-03-18 05:31
    Have a look at the little spin-loader I posted a while back, it allows you to load an arbitrary spin .binary into any location in memory and run it from there. No compiler modification required. Basically it patches the start of the binary (PBASE/VBASE/DBASE) and away it goes. It might be an easy way to do what you need.

    <edit> I realise that will be almost impossible to find..
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      LoadBase = $388
    
    OBJ
      i2cObject     : "basic_i2c_driver"
    
    PUB Go | EAddr, PAddr, Length, i
        dira[noparse][[/noparse] 7] := 1
        i2cObject.Initialize(28)
        PAddr := LoadBase
        EAddr := 0
    
        outa[noparse][[/noparse] 7] := 1
        i2cObject.ReadPage(28, $A0, EAddr, PAddr, 12)
        Length := Word[noparse][[/noparse] LoadBase+$A]
        i2cObject.ReadPage(28, $A0, EAddr, PAddr, Length)
    
        ' Fixup
        Repeat i from 0 to 4
          Word[noparse][[/noparse] LoadBase+6+i<<1] += LoadBase
    
        Cognew($F004, Loadbase+4)
        repeat
          outa[noparse][[/noparse] 7] := cnt[noparse][[/noparse] 23]
                                         
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2009-03-18 06:00
    One of my favourite topics [noparse]:)[/noparse]

    Provided you can start it you can actually run a any spin object from any location with almost no change to the object you are running.

    This is my go at doing it although it desperately needs updating... http://forums.parallax.com/showthread.php?p=701497

    If you have any questions feel free to ask, if I miss them here in the forum just send me a pm.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-03-18 16:58
    Hello Bill,

    as SPIN is not designed to do overloading RAM-areas with new parts of code what is the reason to do this ?

    Of course you can do overloading by special objects like mentioned above but why do you need it?
    Are you running out of RAM ? If not I can't see any reason why overloading should make things easier
    (except maybe transferring complex c-programming techniques into SPIN because you are used to use them)

    best regards

    Stefan
  • Bill HenningBill Henning Posts: 6,445
    edited 2009-03-18 17:41
    BradC:

    Thanks, that helps!

    stevenmess2004:

    Thank you - I don't know how I missed that thread. Looks good.

    StefanL38:

    I need it for the operating system for the Propeller that I've been developing for quite a while. It's just not ready to be shown yet, but it should be in a couple of months.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com - a new blog about microcontrollers
Sign In or Register to comment.