PASM - How cogs are loaded
lanternfish
Posts: 366
The subject line would appear to be a statement when in fact I have a question (or two) that need answering.
If I load a SPIN/PASM program like this:
I observe that the COG 0 has all the code; the COG 1 is loaded with code from the second block on; and so on to the COG 3 only having its block of code.
Q1. Is this standard?
Q2. If not, how do I only get each COGs specific code to load only to that COG?
Clearly I have misread or overlooked another obvious piece of info.
Cheers
If I load a SPIN/PASM program like this:
PUB Main {Launch COG's} coginit(3, @InitCOG3, 0) 'Launch COG 3 coginit(2, @InitCOG2, 0) 'Launch COG 2 coginit(1, @InitCOG1, 0) 'Launch COG 1 coginit(0, @InitCOG0, 0) '(Re)Launch COG 0 CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 DAT {COG0 Code Block} COG0 PASM here {COG1 Code Block} COG1 PASM here {COG2 Code Block} COG2 PASM here {COG3 Code Block} COG3 PASM here {Other Code Blocks Here}
I observe that the COG 0 has all the code; the COG 1 is loaded with code from the second block on; and so on to the COG 3 only having its block of code.
Q1. Is this standard?
Q2. If not, how do I only get each COGs specific code to load only to that COG?
Clearly I have misread or overlooked another obvious piece of info.
Cheers
Comments
I wouldn't call it standard, it's just the way it is. The internal loader always executes 512 rdlongs (blanking the last 16). Side effect is that data after your effective code block ends up in the cog as well. So either your code doesn't care what's in the unused area (usually occupied by res) or you have to clear it yourself (e.g. if you want to place an array there).
Note: This is not correct. res only creates a placeholder with the name and address. It does not occupies anything.
Because addresses will be forced to start at the ORG's value... be aware of this small but common mistake ! (at least I forgot plenty).
Minor misunderstanding, occupied probably being the wrong word. I should have said used by. Does that sound better to you?
That said, res does live in the unused area so it does occupy it
org 0
jmp #initlabel
maincode
{usual pasm code}
initlabel
{init code}
jmp #maincode
fit 496
org initlabel
{res statements}
fit 496
This automatically overlays uninitialized storage on top of init code without a lot of thinking about where everything ends up.
Sandy