Article View: comp.arch
Article #10859Re: Any use for Branch if Even/Odd ?
From: leichter
Date: Sat, 12 Dec 1992 15:45
Date: Sat, 12 Dec 1992 15:45
40 lines
2871 bytes
2871 bytes
Some conditions can be tested very cheaply, others on more expensive. On the VAX, you could test the bottom bit of any value (in register or in memory) in a single short instruction using BLBS/C (Branch on Low Bit Set/Clear). You could test ANY bit in a longword with a single slightly more expensive instruction (BBS/BBC - Branch on Bit Set/Clear; you specify the bit number). Any other tests are done through the condition codes, so require two instructions, nominally a TST of the appropriate kind and a branch. As others have noted, the low bit is used in VMS to signify truth/falsity or success failure. C is the only language I can think of that explicitly defines false as zero and true as non-zero; using 0 and 1 is a much more common representation for a Boolean value. (-1 and not -1 are another reasonable alternative on a two's-complement machine; 0 and -0 are reasonable on a 1's complement machine. Either of these might be - and has been - simplified into <0 for true, >=0 for false - i.e., test the TOP bit.) In addition, there are many cases in which you with to indicate not just success or failure, but further status information. As also already noted, the standard VMS representation of a status uses the bottom bit for success/failure and the rest of the value for an explanation. The VAX hardware was designed along with VMS, and this representation was chosen with the knowledge that the hardware would provide a very cheap low- bit test, and vice versa. VAX programmers know this, and, for example, when setting aside a series of status bits in a longword, try to store the most commonly tested one as the bottom bit. Put it all together, and "test bottom bit" is a very high frequency operation in running VMS code. It's also an easy instruction to implement in hardware. Hence, it's a natural for inclusion in the Alpha instruction set. BTW, this should again prove that you have to be careful about what you are designing "objectively" for. If you start with a sample of Unix systems running C code, you are unlikely to find much demand for a cheap low-bit test. That doesn't meant that such an instruction wouldn't carry it's own weight - just that it would not do so in a job mix similar to the ones you studied. -- Jerry
Technical Details
Message-ID:
<1992Dec12.104554.1@zodiac.rutgers.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!concert!gatech!rpi!uwm.edu!psuvax1!rutgers!igor.rutgers.edu!zodiac.rutgers.edu!leichterReferences:
<endecotp.723992157@cs.man.ac.uk> <MOSS.92Dec11172728@CRAFTY.cs.cmu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!concert!gatech!rpi!uwm.edu!psuvax1!rutgers!igor.rutgers.edu!zodiac.rutgers.edu!leichter From: leichter@zodiac.rutgers.edu Newsgroups: comp.arch Subject: Re: Any use for Branch if Even/Odd ? Message-ID: <1992Dec12.104554.1@zodiac.rutgers.edu> Date: 12 Dec 92 15:45:54 GMT References: <endecotp.723992157@cs.man.ac.uk> <MOSS.92Dec11172728@CRAFTY.cs.cmu.edu> Sender: news@igor.rutgers.edu Organization: Rutgers University Department of Computer Science Lines: 40 Nntp-Posting-Host: pisces.rutgers.edu