Shop OBEX P1 Docs P2 Docs Learn Events
assembly code goes in hub ram or cog ram? — Parallax Forums

assembly code goes in hub ram or cog ram?

fezmonkeyfezmonkey Posts: 41
edited 2010-06-12 17:36 in Propeller 1
I have gone through some docs but I have this foggy area! confused.gif

Please correct me if I am wrong
Is it correct that the assembly code is loaded/executed in the cog's memory?
This assembly code can use the same cog memory for data but there are instructions to access the hub memory?
The spin interpreter is loaded in cog0 (or other) and then the spin program is loaded in the hub for interpreter to execute? But where is it loaded in the hub ram?

I guess my biggest point of confusion is that if you write code that is asm/spin then where does your program go? hub ram or cog ram?
Then also, when I make a new "newcog" then how is the program loaded and what is the mechanism for starting the new cog?

Comments

  • MacTuxLinMacTuxLin Posts: 821
    edited 2010-06-12 12:07
    Hi,

    I was like you when I started with Propeller but I soon got all that sorted after going throught those online manual @ http://www.parallax.com/tabid/832/Default.aspx#Manuals and doing those examples in PE kit.
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-06-12 12:10
    The Spin compiler in the Propeller tool puts the asm code into the hub, and the cognew loads it into the cog from the hub.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
    My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
    and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
    Las - Large model assembler Largos - upcoming nano operating system
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-06-12 17:09
    In the boot-process the propeller starts one COG that tries to load a full 32kB image from serial interface/EEPROM to HUB-RAM. If successfull it loads the SPIN-interpreter code into a COGs RAM. The SPIN-interpreter then starts to execute the first function of the code. SPIN code itself stays in HUB-RAM.

    Whenever you do a cognew giving another funktion, another SPIN interpreter is loaded into another COGs RAM which executes the SPIN function. Again the SPIN code stays in HUB-RAM.

    Whenever you do a cognew giving a pointer to a dat section the 496 longs will be loaded into the COG-RAM.

    It's easy ... all PASM code runs in COG-RAM - the SPIN interpreter is also a PASM program ... all SPIN code stays in HUB-RAM.
  • fezmonkeyfezmonkey Posts: 41
    edited 2010-06-12 17:24
    So everything is always in the hub ram (after it was copied from EEPROM) with cog0 running the spin interpreter to get the program started.
    After that, there are 2 options to start other cogs:
    1. a cognew on spin code causes new cog to start with spin interpreter that would run the corresponding spin code
    2. a cognew on pasm code causes the pasm code to be copied from hub ram to the new cogs ram and then the new cog start executing it

    Is this correct?
  • jazzedjazzed Posts: 11,803
    edited 2010-06-12 17:36
    fezmonkey said...
    So everything is always in the hub ram (after it was copied from EEPROM) with cog0 running the spin interpreter to get the program started.
    After that, there are 2 options to start other cogs:
    1. a cognew on spin code causes new cog to start with spin interpreter that would run the corresponding spin code
    2. a cognew on pasm code causes the pasm code to be copied from hub ram to the new cogs ram and then the new cog start executing it

    Is this correct?
    You got it. On #2. you can recycle or over-write the cog's HUB space if you like.

    PASM instructions like wrlong/rdlong and friends, lockset and friends, coginit, cogid, etc... all use round-robin access to hub memory. It is often easier and in some cases faster to use rd/wr PASM variants instead of using self-modifying code in a cog for manipulating data.

    Cheers.
    --Steve

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Pages: Propeller JVM
Sign In or Register to comment.