home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / arch / 11590 < prev    next >
Encoding:
Internet Message Format  |  1992-12-12  |  2.8 KB

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