wc,wz,etc - a question
pik33
Posts: 2,398
I don't fully understand working of wc and wz modifiers.
For example:
when
If first answer is correct - how o write
I want something like this:
so if a=b then do these three subs; but I don't know if these subs writes flags or not, so I did it in this way
maybe wasting a long and 4 cycles for jump.
For example:
when
sub a,bis a zero flag set always when result is 0, or I have to write
sub a,b wz?
If first answer is correct - how o write
sub a,bin way that flags will not be overwritten?
I want something like this:
cmp a,b wz if_z sub c,d if_z sub e,f if_z sub g,h
so if a=b then do these three subs; but I don't know if these subs writes flags or not, so I did it in this way
cmp a,b wz if_nz jmp next sub c,d sub e,f sub g,h next rest_of_code
maybe wasting a long and 4 cycles for jump.
Comments
C.W.
Having the flags unaffected by default makes it easy to see which instruction last affected the flag you're testing which I think makes PASM easier to comprehend.
[ BTW the assembler reference always shows you the defaults for the WZ,WC and R flag modifiers for every instruction - read the whole section 2 or 3 times and you'll save a lot of time in the future I think ]
This is a very valuable feature of the Prop instruction set architecture, can save a lot of testing and jumping which is important if you have such a limited space to work in as the COG does.
Can't remember the details but you will find that some instruction mnemonics are actually the same opcode but with different settings for nr. So sub and cmp are the same except cmp has nr set.
This assembler reference fooled me with these defaults; I thought when using "sub" wz is set by default and did't know how to switch it off.