GETREGS(HubAddr, CogAddr, Count) Spin2 Syntax Question
Bob Drury
Posts: 236
in Propeller 2
Does someone have an example GETREGS. If you have 3 cogs running how is it bes to distinquish registers.
Regards and Thanks
Bob (WRD)
Comments
GETREGS copies registers from cog memory to hubmemory. You can only copy the registers from the cog that executes the GETREGS methode, there is no way to access registers from other cogs.
If you want to pass registers between cogs you need to go over hubmemory and all the cogs must cooperate.
No Luck. I don't see what this command GETRGS(HubAdr0,CogAdr0,2) does. I would expect HubAdr0 and HubAdr1 would match
CogAdr0 and CogAdr1. Could someone check below and see what is wrong.
Regards
Bob (WRD)
You need to write the values first into the cogregs, I use inline assembly here, to not use SETREGS, that would be too easy
Then you need to pass the address of the hubvariables and the cogregs as parameters in GETREGS.
And now an exercise for you: Why do you get the 55 and 66 for CogAdr0/1 at debug?
I see that the key appears to be @ and # to get hubAdr you need @HubAdr0 and to get CogAdr you need #CogAdr0.
I believe that debug will read the HUB RAM and the Inline assembly is writing to COG RAM and since the DAT table is in HUB RAM a wrlong would be require to load CogAddr0\1 in HUB RAM to get 11\22 present. Going to play with this tomorrow.
I think I am missing something concerning how spin2 boots and what ORG 0 and ORG H do in both assembly and spin2. (actually I'm missing more than this but it's fun)
thanks for info
Regards
Bob (WRD)
The key thing to remember is that "ORG n" does not actually place anything in COG memory -- it merely tells the assembler to prepare the code so that it could be loaded into COG memory at address n. Actually getting it into some COG's memory requires a COGINIT or similar call.
From the following code I believe the CALL instruction results in the HUBEXEC is the only mode running. ORG 0 does not come into play and ORG H doesn't matter also. Am I correct to say that if spin2 interperter is loaded only HUBEXEC can run or you must program a transfer of HUB RAM containing the Cog code to COG RAM then create a jmp to start of Cog program.
thanks for looking at this
Regards
Bob (WRD)
I think I found out that it's true and you have to use REGLOAD\REGEXEC to get something into Cog 0 (ie DAT symbols) I look a little silly with above question
Bob (WRD)