cnt question
K2
Posts: 693
in Propeller 1
With an instruction like:
wrlong cnt par
Will the value of cnt transferred be the value
when the instruction is encountered
or when the transfer actually takes place?
wrlong cnt par
Will the value of cnt transferred be the value
when the instruction is encountered
or when the transfer actually takes place?
Comments
Page 9 of the Propeller data sheet describes the execution stages.
https://www.parallax.com/sites/default/files/downloads/AN009-ExecutionTime-v1.0.pdf
Shadow: a register location on the <Left side> of a instructions, so it's not a <destination rule> as for WRLONG it may look like you're pointing to source-side-cnt
that hardware will not update the "left side version of cnt" and should just be treated as free ram.
You could do a mov cnt,cnt first if you want to send the cnt value.
The shadow register matter is a new complication. Since wrlong operates differently than other instructions, in the sense that data flows l-to-r in its specific case, I figured cnt could be used where normally a destination is specified. (I remember some interesting discussions involving shadow registers years ago. When I have time I'll look up those old posts and try to educate myself regarding that whole business.)
Anyway, I ended up doing as tony suggests: I saved the instantaneous value of cnt to a local register and then transferred it to HUB with a second instruction. Works great. Still leaves me wondering if I could have coded it better.
These below are both the same:
mov CNT,CNT 'copy value to shadow.
mov $1F1,CNT 'copy value to shadow.
The intented use of CNT is read-only, right-side/source-side only.
so the cogs hardware overrides the cogs local ram address of $1F1 when it's on the right side/source side and reach out the global system counter.
It's not hard to imagine that the left-side shadow-register just sit there dormant.
WRLONG uses it as "source" but the hardware don't override left side use of $1F1