"Aliasing" in PASM question
K2
Posts: 693
Can't seem to get my head around Beau's use of phx in Sinewave_v2.1 The value is just an ADD instruction with specific S and D values, yet he does math on it. Say what?! Is that location simply being recycled, in lieu of REServing another long at the end of the DAT section?
Second question: How does one edit the title of a thread?
Second question: How does one edit the title of a thread?
Comments
For example in an instruction like: Y is the address form which the number to be added will be fetched. The source.
If you look in the Propeller manual you will see that the source field of the add instruction is in the lower 9 bits.
So, what happens if you add one to the ADD instruction itself?
It will, when executed next time, add a different number to the Y. The next number up in COG memory from the last one it used.
You can imagine using this for adding up arrays of numbers and so on.
"Self modifying code" is a very common technique in Propeller PASM as it's the only way to make "indexed addressing" for when you want to step though arrays and such.
Do note that you have to put an instruction or two (1 or 2?, I forget) between the instruction being modified and the one doing the modifying to let the change have time to take effect before it gets executed.
Edit: Of course it could also simply be that the instruction you are talking about is only executed once at start up and then that space can be used as a variable afterwards.
BTW, I note that Ahle2 carried on this register reuse tradition with 'out' in his nifty PropellerSignalGenerator.spin.