How would this assembly compile?
Steel
Posts: 313
So I am looking at this code:
___________________________________________________
PUB DO_THINGS
···
·· COGINIT(1,@DO_THING_1,0)
·· COGINIT(2,@DO_THING_2,0)
·· COGINIT(3,@DO_THING_3,0)
DAT
·· ORG·· 0
DO_THING_1
·· {THIS CODE WILL CONTINUALLY LOOP}
·· JMP· #DO_THING_1
DO_THING_2
·· {THIS CODE WILL CONTINUALLY LOOP}
·· JMP· #DO_THING_2
DO_THING_3
·· {THIS CODE WILL CONTINUALLY LOOP}
·· JMP· #DO_THING_3
THING_1_CON_1··· Long·· $0
THING_1_CON_2··· Long·· $0
THING_2_CON_1··· Long·· $0
THING_2_CON_2··· Long·· $0
THING_3_CON_1··· Long·· $0
THING_3_CON_2··· Long·· $0
_______________________________________________________
When this code is compiled, does the entire DAT get copied to every cog...or does just the section that is called by the "COGINIT" Command get copied to the cog?
When this code is compiled, do all of the declared constants get compiled onto every cog, or just the cog that runs the ASM that calls them?
·
___________________________________________________
PUB DO_THINGS
···
·· COGINIT(1,@DO_THING_1,0)
·· COGINIT(2,@DO_THING_2,0)
·· COGINIT(3,@DO_THING_3,0)
DAT
·· ORG·· 0
DO_THING_1
·· {THIS CODE WILL CONTINUALLY LOOP}
·· JMP· #DO_THING_1
DO_THING_2
·· {THIS CODE WILL CONTINUALLY LOOP}
·· JMP· #DO_THING_2
DO_THING_3
·· {THIS CODE WILL CONTINUALLY LOOP}
·· JMP· #DO_THING_3
THING_1_CON_1··· Long·· $0
THING_1_CON_2··· Long·· $0
THING_2_CON_1··· Long·· $0
THING_2_CON_2··· Long·· $0
THING_3_CON_1··· Long·· $0
THING_3_CON_2··· Long·· $0
_______________________________________________________
When this code is compiled, does the entire DAT get copied to every cog...or does just the section that is called by the "COGINIT" Command get copied to the cog?
When this code is compiled, do all of the declared constants get compiled onto every cog, or just the cog that runs the ASM that calls them?
·
Comments
Say, I've three programs that all are 50 longs each. If they are in the DAT, back to back, will all of them end up in the first COG?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
The answer is: YES and NO
In the OP's example - Cog 1 is loaded with Cog 1 code, followed by Cog 2 code, followed by Cog 3 code, followed by <whatever> - Cog 2 is loaded with Cog 2 code, followed by Cog 3 code, followed by <whatever> - Cog 3 is loaded with Cog 3 code followed by <whatever>.
Although ... shouldn't there be an "ORG 0" before each DO_THING_x ?
Post Edited (hippy) : 8/28/2007 4:48:29 PM GMT
I've simply not read that part, and asked the question out of topical interest. There are some specific things I need to work through and this isn't one of them at the moment. Don't take that as failure or lack of clarity on your excellent tutorial. It isn't.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Warning! This means THING_3_CON_1 is translated relative to DO_THING_3.· The code in DO_THING_1 will not be able to access anything after the ORG 0 without some additional trickery even if it's within 496 longs of DO_THING_1.· (Not to mention that each cog is working on a local copy, so updates aren't reflected across cogs.)
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.