What am I after this time? Find a way of determining whether you ran out of cogs using as little resources as possible. This includes s/w as well as h/w.
You didn't specify whether the test was to be carried out in Spin or PASM. Which is it to be? I think it's also important to stipulate that if a cog is started because of the test, its effects must be nil, and it must be stopped. I think you also need to stipulate that the test be independent of anything that happens in the cogs that are running. IOW, they should not need to contribute to -- or be aware of -- the test.
I think it's also important to stipulate that if a cog is started because of the test, its effects must be nil, and it must be stopped. I think you also need to stipulate that the test be independent of anything that happens in the cogs that are running. IOW, they should not need to contribute to -- or be aware of -- the test.
You'd think I learnt something regarding how much info I must include to keep you happy OK, for this exercise I might as well demand PASM.
As for the other two criterias, admittedly I was afraid of stating the obvious. Not much good if you tear down the whole system by doing a simple test.
minimal to no impact on the running system, as stealthily as possible
no resource leaks (rogue cogs)
Did I miss anything?
Note, the test is done as part of your normal code so the PASM cog isn't started for the sake of the test.
Well done! That's what I had in mind. Either of rdxxxx/wrxxxx, cogid and clkset can be used. coginit and cogstop exhibit the same behaviour but have unwanted side effects.
That said, the latest manual specifies carry cleared for most of them. Go figure.
Among that group of instructions, only cogid can be completely neutralized with the nr setting.
That said, the latest manual specifies carry cleared for most of them. Go figure.
The documenters must've felt it was not important enough to note -- or else they just didn't know about it. But yes, saying "0" is different than saying "-". In any event, this is useful enough to deserve being a separate instruction: cogtest. Now where's that macro assembler?
Out of curiosity, how did you arrive at your solution? I had mov[dis] and jmp[ret] figured out [post=864343]a while back[/post] and rdxxxx/wrxxxx were on my list for today.
Out of curiosity, how did you arrive at your solution?
The biggest clue, of course, was that it was you posing the question. That immediately suggested undocumented behavior. From there, I went to the instruction cheat sheet that I keep handy. With that, it's easy to spot instructions with similar bit patterns. The four hub instructions with S.bit2 == 0 (cogx's and clkset) stood out as a group, so it seemed natural to think they might all treat the carry flag the same if it wasn't committed to some other purpose -- and it's not. Among those, cogid is the only one that can be completely neutralized with nr, so it's the only one I tested.
I'm surprised that rdxxxx and wrxxxx behave that way, too, since they're not in that group. But I would almost bet that if bit 2 of S in those instructions is a one, the carry flag will return lock status instead.
Now, here's a follow-on puzzle: Is there an easy, non-destuctive way to tell if a particular cog is being used? (I haven't come up with an answer, BTW, and suspect it can't be done without cognewing the remaining cogs and eliminating their IDs from a pre-populated list.)
Comments
-Phil
This time you're right. That's way too heavy. But at least that gives us something to work on.
-Phil
As for the other two criterias, admittedly I was afraid of stating the obvious. Not much good if you tear down the whole system by doing a simple test.
- minimal to no impact on the running system, as stealthily as possible
- no resource leaks (rogue cogs)
Did I miss anything?Note, the test is done as part of your normal code so the PASM cog isn't started for the sake of the test.
Here's my test code:
-Phil
BTW, I'm guessing that, due to symmetry, clkset exhibits the same carry behavior, but I've not tested it.
That said, the latest manual specifies carry cleared for most of them. Go figure.
The documenters must've felt it was not important enough to note -- or else they just didn't know about it. But yes, saying "0" is different than saying "-". In any event, this is useful enough to deserve being a separate instruction: cogtest. Now where's that macro assembler?
-Phil
Fair enough. I was thinking more like that if you do a hub access anyway (as part of your code) you might as well force wc and look at it later.
-Phil
I'm surprised that rdxxxx and wrxxxx behave that way, too, since they're not in that group. But I would almost bet that if bit 2 of S in those instructions is a one, the carry flag will return lock status instead.
Now, here's a follow-on puzzle: Is there an easy, non-destuctive way to tell if a particular cog is being used? (I haven't come up with an answer, BTW, and suspect it can't be done without cognewing the remaining cogs and eliminating their IDs from a pre-populated list.)
-Phil
Touch
Now, what do the unimplemented instructions MUL (000100), MULS, ENC, ONES do?
IIRC they clear the destination register and therefore set Z if you wish (on my demoboard that is). But that was only from a quick test.