P2 Tips, Tricks & Caveats

This thread is just for listing P2 Tips, Tricks & Caveats.
Please keep discussion to a minimum on this thread.
Examples would be nice.
Links to discussions would be nice.
Please keep discussion to a minimum on this thread.
Examples would be nice.
Links to discussions would be nice.
Comments
They are set from the result rather than the source???
Does not flush the pipeline. It acts as a multiple clock instruction rather than "x" single clock instructions.
This difference can be important in multiple tasks and threads where the pipeline needs to be flushed under certain conditions.
(more explanation needed later)
http://forums.parallax.com/showthread.php/154681-NOP-vs-WAIT-as-pipeline-fillers?p=1250717&viewfull=1#post1250717
PUSHZC rotates ZC flags into D register bits 1:0. Bits 31:30 of D are rotated into ZC flags if WZ WC effect is included. +-----------> Z flag ----+ | | | +-------> C flag ------+ | | | | WZ WC | | | | ^ ^ | | | | V V 31 30.................... 1 0 <----------------------- rotated left x2 POPZC rotates buts 0:1 of D register into ZC flags. ZC flags are rotated into Bits 31:30 of D if WZ WC effect is included. +------------ Z flag <---+ | | | +-------- C flag <-----+ | | | | | | WZ WC | | ^ ^ | | | | V V | | 31 30.................... 1 0 -----------------------> rotated right x2
PUSHZC zc_reg INCMOD myreg,#13 wz,wc PUSHZC zc_reg
In this example the lower 4 bits of zc_reg conatin the before and after ZC flags status. Very useful