Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!agate!pasteur!ames!hao!gatech!purdue!i.cc.purdue.edu!k.cc.purdue.edu!l.cc.purdue.edu!cik From: cik@l.cc.purdue.edu (Herman Rubin) Newsgroups: comp.arch Subject: Re: Condition Codes in General Registers Message-ID: <682@l.cc.purdue.edu> Date: 18 Feb 88 20:19:03 GMT References: <191@telesoft.UUCP> <1556@gumby.mips.COM> <208@telesoft.UUCP> <868@ut-emx.UUCP> Organization: Purdue University Statistics Department Lines: 50 Summary: This is not what was asked In article <868@ut-emx.UUCP>, reeder@ut-emx.UUCP writes: > In article <6834@sol.ARPA>, crowl@cs.rochester.edu (Lawrence Crowl) writes: ...... > > compare R1 with R2 place condition code in R3 > > branch to ADDRESS if condition code in R3 is GREATER > > branch to ADDRESS if condition code in R3 is EQUAL > > branch to ADDRESS if condition code in R3 is LESS ...... > That is exactly how you do things on a Cray, for example: > > A0 A1-A2 Compare A1 and A2 > JAP addr1 Branch to addr1 if A1 > A2 > JAZ addr2 Branch to addr2 if A1 = A2 > JAN addr3 Branch to addr3 if A1 < A2 This is not the same. The first instruction computes a value and inserts it in A0. The other instructions perform a test on the value in A0 and use _that_, not the bits in a condition code, to decide whether to perform the branch. To clearly see the difference, suppose that several condition codes were involved in a branch situation. On a Cray, the appropriate values would have to be stored in various A or S registers, and _for each situation for which a jump is contemplated_, the appropriate value would have to be stored in A0 or S0 and then tested. It is not possible to directly move A0 or S0 to another A or S register, either. On machines which can do the more common type of tests, it is no faster to compute the difference and transfer on it rather than transferring on the comparison. Furthermore, this does not allow the condition codes to be used for overflow or carry. Of course, the Cray is not too well suited for integer multiplication or any kind of division, but it is well suited for integer addition and shifts, and that is where overflow and carry are important. Let me make some additional suggestions apropos of Crowl's posting. It should be possible to address an arbitrary byte of a register (this is useful for other purposes). One way of doing this is to make a small address a reference to the register file; on virtual machines this would be costless, and the amount of memory lost on non-virtual machines would be negligeable. Some machines have done this, but I do not believe that they have done it well; either this can only be used in certain situations, or the user's registers are in blocks and/or separated from main memory. If we do this, we can keep many condition codes active for transfers. -- Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907 Phone: (317)494-6054 hrubin@l.cc.purdue.edu (ARPA or UUCP) or hrubin@purccvm.bitnet