Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!chris
From: chris@umcp-cs.UUCP (Chris Torek)
Newsgroups: net.lang.c
Subject: Re: Numeric comparisons
Message-ID: <1657@umcp-cs.UUCP>
Date: Sat, 21-Sep-85 03:36:53 EDT
Article-I.D.: umcp-cs.1657
Posted: Sat Sep 21 03:36:53 1985
Date-Received: Sun, 22-Sep-85 06:41:32 EDT
References: <797@dataio.UUCP> <726@terak.UUCP>
Organization: U of Maryland, Computer Science Dept., College Park, MD
Lines: 31

>> I disagree. A comparison is a subtract with the result thrown away. The
>> trick is to select the correct conditional branch instruction afterwards,
>> depending on whether a signed or unsigned comparison was done.

> Watch my lips!  A signed comparison is *not* a subtract with the result
> thrown away.  Write that down so you don't forget it.

> I offer another example... take an 8-bit machine, both for simplicity
> and because the 8080A/Z80/6502 all did compares via subtraction.

Watch my fingers!  A signed comparison is a subtract with the result
thrown away.

I offer another example.  Take a 32 bit machine---the Vax---both for
simplicity and because the Vax does compares via subtraction.  But I
will use a byte instruction:

	cmpb	r1,$40
	blss	label		# branch if less than

If you wish to do an unsigned comparison:

	cmpb	r1,$40
	blssu	label		# branch if less than unsigned

Can we lay this to rest?  How the compiler implements comparison
is machine dependent.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland