Set / Clear Flags
JonnyMac
Posts: 9,566
A long time ago there was a thread about setting and clearing the C and Z flags -- can't seem to find it. The thread may have been started by Phil, but I think it was in the old forums because a bookmark I have is broken.
Does anyone have a link or cool PASM tips for setting and clearing the C and Z flags? My immediate need is to clear the C flag; this is what I'm thinking:
Does anyone have a link or cool PASM tips for setting and clearing the C and Z flags? My immediate need is to clear the C flag; this is what I'm thinking:
xor $, $ nr, wc ' clear c flag

Comments
http://forums.parallax.com/showthread.php/108002
-Phil
{ C=0 Z=0 } cmpsub outb, #1 wc,wz { C=1 Z=1 } cmpsub outb, #0 wc,wz { C=0 Z=1 } cmp outb, #0 wc,wz { C=1 Z=0 } cmp outb, #1 wc,wzJonathanI believe that this code below will save both the Z & C flags and restore them.
save flags
muxnz ZC, #2
muxc ZC, #1
restore
sar ZC, #1 wz, wc
HydraHacker
Very slick, indeed (but don't forget to wc,wz in the sar).
I added the WZ and WC effects, I had it wrote down on my paper but forgot to include it.
HydraHacker