Shop OBEX P1 Docs P2 Docs Learn Events
Spinneret need more Space — Parallax Forums

Spinneret need more Space

PodionPodion Posts: 90
edited 2012-10-19 14:07 in Propeller 1
Hello all

It is possible to store some spin code in the SD card?
I need more space!
And if it's possible, is there a OBE already for doing that ?

Comments

  • msrobotsmsrobots Posts: 3,709
    edited 2012-10-18 19:11
    Podion,

    short answer - no, but...

    what you can do is reuse the space used for PASM-parts of your program after starting the PASM-cog for VAR-space.

    If you need your project to restart PASM you can save the PASM-dat to a file and reload it from there or read it out of the eeprom again.

    You also can go to your included sub-objects and comment out unused methods.

    Hm. And you can allways recode and optimize.

    But if it don't fit after compiling - well - then it is to big for P1 you need to wait for P2.

    Enjoy!

    Mike
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-10-18 19:49
    If you use several objects with a lot of methods. Have you tried compiling your code with bst (Brad's SPIN Tool) which has an option to eliminate unused methods?

    best regards
    Stefan
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-10-18 20:17
    If you've got HTML embedded in your Spin code, make a file of it on the SD card instead. HTML text is a memory hog and doesn't need to be kept in hub RAM. It can be pulled from SD on an as-needed basis.

    -Phil
  • MagIO2MagIO2 Posts: 2,243
    edited 2012-10-19 09:51
    Well .. well ... well .... possible, but that's the one of the things that's not so easy to have!

    You really need to tell what you currently have and what the goal is! How many COGs are busy with running low level drivers and how many low level drivers do you need to use from the SPIN part you want to load from SD? Or are the SPIN snippets you want to load totally independent?
    What shall happen to the loading code? Does it have to continue or can it be replaced?

    If you store your program as binary you can load it into any buffer, fix some pointers and run it in a new COG like this:
    pub runbin
      ' Fixup the pointers
      repeat i from 0 to 4
        word[@ld_buffer+6+i<<1] += @ld_buffer
       
      ' passing parameters to the loaded program
      j := word[@ld_buffer+$a]
      long[ j+4 ]:=1
      long[ j+8 ]:=@par_cnt  ' par_typ
       
      ' start the SPIN-interpreter 
      i:=cognew($F004, @ld_buffer+4)
    
    ld_buffer is the buffer which contains the loaded *.binary file.

    The dangerous thing is, that the buffer has to be big enough to hold the program AND the main-stack of the SPIN-code. Otherwise your loaded code would overwrite the stack of the loading code.

    It's also easily possible to reload the whole memory with a new program.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-19 09:56
    Wonder when we'll see the Spinneret code ported over to PropGCC... Seems like that would be a good match.
  • max72max72 Posts: 1,155
    edited 2012-10-19 14:07
    There are also the cogjects.
    forums.parallax.com/showthread.php?130537-Cogjects-load-cog-code-from-SD-and-save-hub-ram

    Massimo
Sign In or Register to comment.