phsx is a very special, special register (pitfalls in PASM)
ags
Posts: 386
Propeller datasheet v1.4.0 states that phx registers are special, even among the 16 already-special cog registers:
OK, I can understand the example using add. phsa is the destination operand, and the add instruction reads the destination value, modifies it, then writes the new value to the destination. Question is, I see the following used all over the place, and it works as expected:
I suppose this is minutia, but perhaps helpful in some cases to know.
PHS can only be read through the sourceoperand (same as PAR, CNT, INA, and INB). Bewarethat doing a read-modify-write instruction on PHS, like"ADD PHSA, #1", will cause the last-written value to beused as the destination operand input, rather than thecurrent accumulation.
OK, I can understand the example using add. phsa is the destination operand, and the add instruction reads the destination value, modifies it, then writes the new value to the destination. Question is, I see the following used all over the place, and it works as expected:
shl phsa, #1Why does this work? How is shl not a read-modify-write instruction? phsa is the destination operand. Its value is read, modified, and then written back to the destination. Is there some concise way of differentiating a read-modify-write from those that are not? What am I missing?
I suppose this is minutia, but perhaps helpful in some cases to know.
Comments
Just like the ADD example. Normally the SHL PHSx,#1 is used for fast SPI and the byte to send is written to the PHSx (left aligned) before the SHL PHSx loop begins, this also writes the shadow register with the same value.
Andy
BTW, the "correct" way to advance or retard the phase of a running counter is to increment or decrement frqx, then set it back to its original value.
-Phil
-Phil
My own hread, too. D'oh!
-Phil
Perhaps they should extend the read-modify-write, to say read(last-write)-modify-write-to-both ?
The video will show both Dest and Source side of PHSx in real-time while a few lines of pasm code is running.