View Full Version : is there any way to limit what range of memory spin runs in?

Bill Henning
03-18-2009, 08:23 AM
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 (http://www.mikronauts.com) - a new blog about microcontrollers

03-18-2009, 12:31 PM
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..


_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
LoadBase = $388

i2cObject : "basic_i2c_driver"

PUB Go | EAddr, PAddr, Length, i
dira[ 7] := 1
PAddr := LoadBase
EAddr := 0

outa[ 7] := 1
i2cObject.ReadPage(28, $A0, EAddr, PAddr, 12)
Length := Word[ LoadBase+$A]
i2cObject.ReadPage(28, $A0, EAddr, PAddr, Length)

' Fixup
Repeat i from 0 to 4
Word[ LoadBase+6+i<<1] += LoadBase

Cognew($F004, Loadbase+4)
outa[ 7] := cnt[ 23]

Cardinal Fang! Fetch the comfy chair.

03-18-2009, 01:00 PM
One of my favourite topics :)

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.

03-18-2009, 11:58 PM
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


Bill Henning
03-19-2009, 12:41 AM

Thanks, that helps!


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


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 (http://www.mikronauts.com) - a new blog about microcontrollers