|
Message
From: Jim Dempsey<tapedisk@a...>
Date: Fri May 14 14:59:46 CEST 2004
Subject: [openrisc] 1 bit condition code register
Much can be done with only a carry bit.For (A<B) you can check the carry from (NOT A) + B Or in the special case of (A==0) check the carry from negating A (same as (NOT A) + 1)
Jim
----- Original Message ----- From: Ben A. Abderazek To: List about OpenRISC project Sent: Thursday, May 13, 2004 9:41 PM Subject: Re: [openrisc] 1 bit condition code register
>You must have in mind that if you have just > one bit then the programs will have to repeat the operations that are > checked as many times as bits in the complete comparison codes are > needed (that is two times for a A<B) and also many branches inside this > code... j
I understand it very well now.
One more question.. assume that we have Z and N flags that can be set only by compare instructions. If we consider the other flags (C(carry) and V(overflow)). Should I let all instructions operating on data values set these flags? If so , how about if more that one instruction wants (forced to ) to set one of these flags? Does this make a problem ? Thanks Lopez /Ben
----- Original Message ----- From: "Victor" <victor.lopez@a...> To: <openrisc@o...> Sent: Thursday, May 13, 2004 9:34 PM Subject: Re: [openrisc] 1 bit condition code register
> Hello Ben > > I am not an authority in this subject but if I am not mistaken the > condition codes that you mention are Z for Zero, N for Negative, C for > Carry and V? I guess it stands for Overflow, anyways the thing is that > maybe this 1 bit condition code is a bit uneffective as many > comparisons in a software program involve checking at least two of the > condition codes. Let's just take a look at comparisons between numbers: > > We have number A and number B both are 2's complement signed integers. > The comparisons in the lowest level are usually done by substracting > one number from the other and doing the comparison of the result with > zero: > > A > B? ====> (A-B) > 0? (See? it is the same comparison) > > This way the comparison would be true if bit Z=0 and bit N=0 (the > result of the substraction is not zero (as it has to be greater than > zero) and it is not negative) > > Another example which only needs one comparison code bit: > > A < B? ====> (A-B) < 0? > > To be True, the comparison ought to check only the N bit to be 1, as > this indicates that the result is negative (that is, less than zero). > > And the same goes with A >= B which requires N=0 > and with A <= B which requires (N=1 OR (Z=1 AND N=0)) which is the same > as, in simplified form, (N=1 OR Z=1) > > A=B and A!=B imply only checking the Z bit (after the substraction A-B) > but as you can see there are cases in which it is wiser to have all the > condition code bits at hand, as we are not messing with a picky program > that checks first if there has been an Overflow (quite a natural thing > to do) or the carry bit. You must have in mind that if you have just > one bit then the programs will have to repeat the operations that are > checked as many times as bits in the complete comparison codes are > needed (that is two times for a A<B) and also many branches inside this > code... just try to assemble by hand any simple program which has to > make integer comparisons and you will see how performance can be > affected. I hope this helped. Regards, > > Victor Lopez > > > > > _______________________________________________ > attachment.htm
|
 |