Multiple Copies of An Object in One Cog
pjv
Posts: 1,903
in Propeller 1
I hope there is some answer for this....
I am wanting to load multiple copies of one object into a single cog. At load time, each one naturally needs to be compiled to a differt ORG location. But I'd rather not create N copies of the object with different ORG offsets.
Is there some clever way to fool the assembler to give different ORGs to each instance as it compiles them?
Would an "IFDEF" construct (if we had that) facilitate this? Or perhaps a Macro capability?
Thanks for your help.
Cheers,
Peter (pjv)
I am wanting to load multiple copies of one object into a single cog. At load time, each one naturally needs to be compiled to a differt ORG location. But I'd rather not create N copies of the object with different ORG offsets.
Is there some clever way to fool the assembler to give different ORGs to each instance as it compiles them?
Would an "IFDEF" construct (if we had that) facilitate this? Or perhaps a Macro capability?
Thanks for your help.
Cheers,
Peter (pjv)
Comments
I think you'll have to write your own cog loader for that. You will need a table of where your cog address references are located so you can add the necessary offsets at load time. ('Too bad the Prop doesn't support relative addressing. )
-Phil
I see gas has .if, .endif, .macro, .exitm, .endm, .rept, .endr
Yes, I was afraid of that. About 4 years ago I did exactly that, but the relocation helper was awkward while code was being developed. Once stable though, it worked fine.
I was hoping for some simple approach though PropellerIDE, or possibly SimpleIDE. But I have not mastered either, so was looking for knowledgeable adviceadvice.
JMG, the whole gas thing is something I am a total ignoramus on. But it would then appear to have things that could work well if I ever figured it out. So perhaps when I get a bit of time I will stick my toe in and see what it feels like.
Thank you both for your comments.
Cheers,
Peter (pjv)
In short, you have a short common cog code and several "sub-programs" all compiled to the same org address, the common cog code loads the sub-program from the hub and executes it as if it is a subroutine.
Hope this helps.