Proper Spin Structure
James Long
Posts: 1,181
I've noticed a large number of post like this....but I don't think this will be a repeat question.
Ok.......I want to start a "cognew" but I want to make sure what this cog can address.
(obj....file)
cognew(real world value(parameters)@stack)
PUB real world value(Parameters)
·· repeat
···· method call
···· method call
The above is what I would like to do....my question. Can the method calls be in the same object file(cognew object file).....or should the methods called from this new cog be in a separate daughter object, or does it matter?
I would like to know what methods are included with the cognew command.......if any. I know the target method is included......are any listed (in the same object) included as well.
I know this is a confusing post.....I'm trying to insure my spin code is structured correctly....before I rewrite.....My cognew command (the structure called) has gotten too complex...and I need to break it down into method calls.
I know all of this would probably be much simpler in assembly.....but I have a dead line....and don't have time to learn assembly at the moment. That will come later.
·James L
Ok.......I want to start a "cognew" but I want to make sure what this cog can address.
(obj....file)
cognew(real world value(parameters)@stack)
PUB real world value(Parameters)
·· repeat
···· method call
···· method call
The above is what I would like to do....my question. Can the method calls be in the same object file(cognew object file).....or should the methods called from this new cog be in a separate daughter object, or does it matter?
I would like to know what methods are included with the cognew command.......if any. I know the target method is included......are any listed (in the same object) included as well.
I know this is a confusing post.....I'm trying to insure my spin code is structured correctly....before I rewrite.....My cognew command (the structure called) has gotten too complex...and I need to break it down into method calls.
I know all of this would probably be much simpler in assembly.....but I have a dead line....and don't have time to learn assembly at the moment. That will come later.
·James L
Comments
Chip Gracey
Parallax, Inc.
The method calls (you mean from inside the method you "launched" into another cog) can be to methods within the same object, or within another object... it doesn't matter.· What DOES matter, however, is that the method you are launching into another cog "real world value" is within the same object as the cognew that is launching it... if it is within another object, the Propeller will actually execute that method and wait for the return value from it and use that return value as the address of the code to launch (that's not what you want to do).
When launching Spin code with cognew, the code itself doesn't get moved anywhere, but rather the new cog gets loaded with the Spin Interpreter code (from ROM) and then it simply starts executing your Spin method from Main RAM.· Effectively, that new cog can execute any Spin code contained within that object that it was launched from (what gets called depends totally on what you've written in the Target Method.
No problem.· That's what Spin is for... quick coding that doesn't necessarily have to run as fast as possible.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Jeff Martin
· Sr. Software Engineer
· Parallax, Inc.
That is exactly what information I was looking for. I wanted to insure the newly started cog could call and use information from (using the parameters) the local object file (in which the cognew command is in).
I wasn't exactly sure of this....and hadn't started my rewrite ......I wanted to make sure before I went and messed up my working code. Yea...I was justbeing lazy.....I have comma's where they belong.
That is basically what Chip said.
I just wanted to ensure what was loaded into the cognew....and what it could actually call from the new cog.
Thanks all,
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski