Forum Update - Announcement about May 10th, 2018 update and your password.

Jumps and flags

I haven't seen an example of using jumps to set/reset flags before, but I've found them to be useful.
I had a few sections of code with something like this:
mov    t1, #0 wz, nr           ' Set Z, don't alter t1
jmp    #loop                   ' Return to loop
But you can do both in one instruction with:
tjz   inb, #loop wz
In effect, we test inb (which is always zero) and perform the branch, setting the Z flag in the process.
Since the jump takes place, it takes only 4 clock cycles.
Conversely, you can reset Z with:
tjnz  nonzeroValue, #loop wz
nonzeroValue obviously has to always be non-zero. Again, since the branch takes place, it takes only 4 clock cycles.
Both instructions can reset C (regardless of the value) if wc is specified.
The propeller manual seems to imply that you can use jmp to set C. In my testing, however, I was unable to do so, at least with the propeller tool. Possibly it ignores wc on this instruction?
In summary, you can:
Set Z and optionally reset C; or
Reset Z and optionally reset C
at the same time you unconditionally jump.
Tulsa, OK

My OBEX objects:
AGEL: Another Google Earth Logger
DHT11 Sensor

I didn't do it... and I promise not to do it again!
Sign In or Register to comment.