I came across some assembly where a vector subtract was used to clear a register instead of a load immediate. Example:
R1 = R1 -|- R1;
What's the advantage of using a vector subtract to clear a data register?
Adv: Arithmatic status bits will be modified according to result, as explained in programming reference manual (PRM).
Disadv: (4 byte opcode) Vs (2-byte opcode for immediate load)
If the purpose it to simply clear the register, what use are the arithmetic status bits?
This instruction, along with select others can be issued in parallel with other specific instructions. See section 20 on Issuing Parallel Instruction in the Blackfin Processor Programming Reference Manual (http://www.analog.com/static/imported-files/processor_manuals/blackfin_pgr.ref.man.rev1.3.pdf) for more information. For this case, we can execute that instruction with a load, for example; R1=R1-|-R1 || R2=[p0++]; This can't be done if you load R1 with 0.
Unrelated: Strange how this board doesn't quote a post that you reply to.
Gabby, so if the instruction isn't used in a parallel issue, then there's no advantage in using the vector subtract?
I think Prashant was just stating a general difference with regards to the status bits.
There is no advantage in using Rx=Rx -|- Rx to clear a register as far as I can see if it's not used to issue a parallel instruction. But as Prashant points out as well, this is a 4 byte opcode as compared to a 2 byte opcode for an immediate load which increases your code size.
Retrieving data ...