How about keeping the spin code to such a minimum that it is easy enough to write the equivalent code in any language? eg
To start
Code:
cog := 1 + cognew(@mycode, @parameters)
To stop
Code:
if cog
cogstop(cog~ - 1)
and to pass parameters and do clever things like pass different commands to a cog to run various routines, just designate one of the longs in the parameter list as a "command" long and change it and the cog code changes it to something else to say it has finished. It will all be very similar in different languages - you talk to a cog by changing a long in hub, and wait for the long to change to signal the routine has finished. All languages can write to and read longs in hub.
If the cog is a "start and run forever" cog, you just run the startup routine.
I suppose the key here is good documentation. For a particular coglet, you might define it has n longs as the parameter list, and they are in a fixed order. So you just need to explain that in a verbose way that is easy to understand.
re ctwardell
By that I mean if I've already created a PASM binary using "normal" propeller assembly in the propeller tool will I be able to use that binary versus needing to code it using GCC or GAS.
That is exactly the idea. You can compile these using the proptool. Save them as a .binary file. Or a .cog file, or whatever you want. Store them on an sd card, or in high eeprom, it does not matter. Once that binary file exists, any language can use it, Spin, C, Basic etc.
This is some code I was using for Catalina that is a skeleton pasm routine that compiles independently using the proptool and which passes a group of variables:
Code:
CON
_clkfreq = 80_000_000
_clkmode = xtal1 + pll16x
PUB Main
coginit(1,@entry,0) ' cog 1, entry, dummy value
DAT
org 0
entry ' start of the cog code
mov arraypointer,par ' arraypointer is the address of the array
rdlong array0,arraypointer ' array0 = array[0]
mov array1,array0 ' array[1]=array[0] - long is 4 bytes so add 4
add array1,#4 ' array[1] += 1 change the value so see cog works
add arraypointer,#1 ' pointer += 1
wrlong array1,arraypointer ' write array[1] back to hub
jmp #entry
arraypointer long $00000000 ' pointer to array[0]
array0 long $00000000 ' first array location
array1 long $00000000 ' second array location
fit 496
Bookmarks