Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!hao!noao!mcdsun!sunburn!gtx!edge!doug From: doug@edge.UUCP (Doug Pardee) Newsgroups: comp.arch Subject: Re: conditional branches Message-ID: <1042@edge.UUCP> Date: 25 Feb 88 20:16:51 GMT References: <191@telesoft.UUCP> <9782@tekecs.TEK.COM> Organization: Edge Computer Corporation, Scottsdale, AZ Lines: 13 Summary: Comparison tests ]I've seen this assertion a couple of times, but it ain't so. You need ]to worry about carry when doing a subtract, but not when just doing a ]compare. If both operands are positive, a simple bit-for-bit ]comparison is sufficient, analogous to the way that C programs compare ]strings. When the operands can be signed, a little extra logic is ]required, but nothing as fancy as a full adder/subtractor. Not only is bit-for-bit comparison sufficient, it should be considered *necessary*. Using subtraction for comparison only makes a mess of things by introducing (unnecessarily) the possibility of overflow when comparing a quite negative number with a quite positive one. -- Doug Pardee {ames,hplabs,sun,amdahl,ihnp4,allegra}!oliveb!edge!doug Edge Computer Corp., Scottsdale, AZ uunet!ism780c!edge!doug