Shop OBEX P1 Docs P2 Docs Learn Events
Code for multiple COGs in a single .spin file ? — Parallax Forums

Code for multiple COGs in a single .spin file ?

I can write multiple pasm section and launch them into several cogs like this and it compiles, don't know if it runs yet:

PUB Main
    cognew(@CODE1, 0)                 
    cognew(@CODE2, 1)                 

' 1st COG code
DAT
                    org     0              
CODE1    
                    ' code here
var1 long 0

' 2nd COG code
                    org     0              

CODE2
                   ' code here
var2 long 0


Will this work?

How does the cognew() know how much code to load to the cogs?

Or does this result in each cog having all the code?

Comments

  • Yes, this should work.

    COGNEW always loads 496 longs of code. If your code is shorter, it'll just load whatever comes after into the remaining registers.
  • Ah, now I see. So it doesn't matter if the all cog code is longer than 496 bytes, loading starts from the address specified and anything that does not fit is effectively ignored. Thanks.
Sign In or Register to comment.