PASM: WAITPNE results and flags
johnfos
Posts: 59
Pursuing my attempts to understand the propeller assembly language, I think I have one last question.
If WAITPNE is used with the wz, wc and wr effects, under what conditions are the flags set and what algorithm determines the result?
I've found a number of posts relating to this, but I haven't been able to piece together the whole picture. Kuroneko has said that the result is D += S + 1, which I don't dispute but which is at odds with the first and last lines of the truth table on page 370 of the propeller manual (v1.1). If the truth table is wrong, it's the only such case I've been able to find.
I've also seen it said that Z is set if the final D value is 0, which makes sense and is in line with the truth table.
And I have no idea how the C flag is set.
By the way, many thanks to Dave Hein for his SpinSim program. Without that, I'd have had a lot more questions. Unfortunately, SpinSim doesn't implement WAITPNE and its chums.
If WAITPNE is used with the wz, wc and wr effects, under what conditions are the flags set and what algorithm determines the result?
I've found a number of posts relating to this, but I haven't been able to piece together the whole picture. Kuroneko has said that the result is D += S + 1, which I don't dispute but which is at odds with the first and last lines of the truth table on page 370 of the propeller manual (v1.1). If the truth table is wrong, it's the only such case I've been able to find.
I've also seen it said that Z is set if the final D value is 0, which makes sense and is in line with the truth table.
And I have no idea how the C flag is set.
By the way, many thanks to Dave Hein for his SpinSim program. Without that, I'd have had a lot more questions. Unfortunately, SpinSim doesn't implement WAITPNE and its chums.
Comments
Why waitpne is special (+1) is everyone's guess but it sure is convenient when you know about it.
Lucky! Imagine you'd found more. While I can't disprove the first line (infinite block) the last line is evidently wrong. Running a test here tells me 5 and both flags clear. If you want to see a zero result check which gives 0 and both flags set.
Regarding the only such case, the carry flag behaviour description/footnote for jmp[ret] is wrong (and so is the truth table). Also, for practical purposes the zero flag is always cleared, the only case where it could be 1 (PC = $1FF) aborts the instruction (nop) so flags are not changed at all.
A It's still add but not as expected.
Brilliant! Did I just open a can of worms?
For the terminally curious the Z flag is actually set for
This raises a new question: is there anywhere a list of known errata in the manual? I can find the list of changes between versions, but if there's an errata list it's eluded me.
This all arose, by the way, in testing my simulator. I wrote a program to parse the instruction descriptions and truth tables out of the manual and auto-generate test programs for most instructions (not jump instructions), so if there are other errors in the manual I may not have spotted them. My simulator is an educational exercise; it's never going to be a rival for SpinSim.
Nothing I'm aware off. Currently I have a support request filed to get the documentation updated (not sure how this will be handled re: QC). Apart from that you'll have to dig through the forum posts or just ask.