Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!cottrell@nbs-vms.ARPA From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES) Newsgroups: net.lang.c Subject: Numerous Comparisons Message-ID: <1819@brl-tgr.ARPA> Date: Tue, 1-Oct-85 13:41:39 EDT Article-I.D.: brl-tgr.1819 Posted: Tue Oct 1 13:41:39 1985 Date-Received: Thu, 3-Oct-85 06:27:26 EDT Sender: news@brl-tgr.ARPA Lines: 31 /* Alan Covington writes: > Chris Torek writes > > 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: > > The VAX cmp and sub instructions set the condition codes differently. > Thus, the cmp is not just a "subtract" with the result thrown away. > An easy example is comparing 0x80000000 and 1 results in the N bit > of the condition codes being set, whereas subtracting 1 from 0x80000000 > results in the overflow bit being set. The VAX may use a subtract as > part of the cmp instruction, but it doesn't do signed comparison as > Chris claims. > > A signed comparison is a subtract with the result > > thrown away. You are correct literally. However, conceptually Chris is correct. You see, we all consider the VAX to be merely a PDP-11 with bells & whistles. On a PDP-11 (which is *the* standard conceptual model for instruxion sets) what he says is true. On a VAX, however, the microcode does all that `N xor V' stuff for you and just sets the result in N for you. The branch instruxions are changed to reflect that fact. Gone is the ability to determine the true sign of a *real* add/sub without testing overflow, but nobody did that anyway. You can trot out examples of what one machine or the other really *does* with compare/subtract, but the *concept* remains the same. jim cottrell@nbs */ ------