Shop OBEX P1 Docs P2 Docs Learn Events
Memory limits — Parallax Forums

Memory limits

jnoguesjnogues Posts: 25
edited 2010-01-09 11:06 in Propeller 1
Hi everybody!
I'm new in propeller and I don't understand the memory limit of propeller.
We have 32 k of main memory, but every Cog have 2k (512 long's).
I think than the limit of a program in a Cog is 512 (496 in Cog 0) spin instruccions.
If my progrmam is longer I need use another cog for some functions.
Is correct?

Regards.

Jaume Nogues
Barcelona
Spain

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-09 08:12
    You are correct about the hub memory bewing 32K bytes (8K longs). However, all cogs are identical, so each has a nominal RAM limit of 496 longs of instruction/data memory. This is because each cog has its own set of special function registers.

    -Phil
  • AribaAriba Posts: 2,690
    edited 2010-01-09 09:37
    .. but you are not correct about the 496 Spin instructions.
    Spin source code is compiled to a bytecode, which stays in the 32k MainMemory. This code is executed by an Interpreter-code in a cog. Only this interpreter must fit in the 496 cog longs. The interpreter reads byte per byte from MainMemory, decodes the instructions and execute theme. This is not really fast, but allows very compact code, which can stay in the bigger MainMemory.

    If you need faster code, then you can start also Assembly code direct in a cog. In this case you are limited to 496 assembly instructions in the cog memory (as long as you don't reload portions of the cog memory from MainMemory with Overlays or LMM).

    Andy
  • VIRANDVIRAND Posts: 656
    edited 2010-01-09 11:06
    You can add memory as eeprom, SD or MMC cards, and some other stuff. A 2GB SD ... WOW, how can you fill it with a Propeller?
    You might not even fill 32K of HUB RAM.

    SPIN programs are in HUB, and SPIN interpreter can be reloaded into extra cogs so you can run two spin programs at the same
    time and speed, or more. That is like having extra chips helping with other programs BUT it is inside the same chip.

    If you connect things like monitor, tv, keyboard, mouse, etc. then the driver for those things each might need a cog,
    but you probably will not run out or even use all 8. With just one spin program doing something simple like blinking LEDs,
    you can write a really long program (if you want to) and it runs in only one cog, the other 7 cogs never get used by that kind
    of program, and only one program has all of the HUB to itself. (The way things work, the programs usually don't notice
    each other even if they are sharing the hub memory. Each has its own code, data, variables and minds its own business.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    VIRAND, If you spent as much time SPINNING as you do Trolling the Forums,
    you'd have tons of awesome code to post!
Sign In or Register to comment.