By whygee on Thursday 13 February 2014, 05:12 - Architecture
RISC does not like status flags, but it was determined to be a necessary evil for the YASEP. Yet something more important than scheduling has confused the flags : their values. They have often created more problems than they solve because I always remember the wrong ideas about them, or I forget that I changed a detail.
The Carry flag
In the beginning, it's very simple : the carry flag is set to 1 if the result of an addition generates a carry (overflows). It's valid both for signed and unsigned, thanks to the magic of 2s complement.
Then comes the subtraction : a little electronic quirk made me chose to not complement the borrow flag when there is a borrow. So the flag is set when there is no borrow. It's not usual but it saves maybe half a nanosecond and it's hidden by the symbolic treatment of the assembler with the "BORROW" condition.
Comparisons and MIN/MAX are even more confusing and I never know what to expect or how to come with the right thought process... The fact that the operands can often be swapped does not help !
(to be continued)
The Equal flag
This one just changed polarity, again. So now it's simple : it is set to 1 when the operands are equal.
The value's calculation is a bit subtle : it reuses the ROP2's XOR layer, but since CMP also performs a SUB in parallel, the SND operand is negated, so it's actually a XORN.
Additionally, the reduction was done by a OR, and now it's done by AND (otherwise it won't work).
The documentation at http://yasep.org/#!doc/reg-mem#equal is updated with a new diagram. This time, I should not forget the subtleties anymore...
20200411:
Oh my, here I go again with these "details"...
SeeLog#62 : Zero becomes Equal and Log#46 : The Zero status flag
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.