home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / arch / 12167 < prev    next >
Encoding:
Text File  |  1993-01-08  |  2.7 KB  |  72 lines

  1. Newsgroups: comp.arch
  2. Path: sparky!uunet!news.uiowa.edu!news
  3. From: jones@pyrite.cs.uiowa.edu (Douglas W. Jones,201H MLH,3193350740,3193382879)
  4. Subject: A better theory for Endian origins
  5. Sender: news@news.uiowa.edu (News)
  6. Message-ID: <1993Jan8.185448.2405@news.uiowa.edu>
  7. Date: Fri, 8 Jan 1993 18:54:48 GMT
  8. References: <1ikepuINNgt7@spim.mti.sgi.com>
  9. Nntp-Posting-Host: pyrite.cs.uiowa.edu
  10. Organization: University of Iowa, Iowa City, IA, USA
  11. Lines: 59
  12.  
  13. The decision whether to go big-endian or little-endian on byte numbering
  14. has natural ties to the bit numbering in a word, and this is, I think,
  15. one of the historical forces behind the war of the endians.
  16.  
  17.    There are a few rational ways of numbering the bits in a word.  One is
  18. to number them left to right:
  19.  
  20.   1 2 3 4 ...
  21.  
  22. This has no particular appeal other than the fact that it is the first
  23. to come to mind when you start numbering parts of a word.
  24.  
  25.  
  26.    Another is to think of the formula for the value of a binary number:
  27.  
  28.   V = Sum( b[i]*2**i )
  29.  
  30. To make this work for integers, you've got to number the bits as:
  31.  
  32.   ... 3 2 1 0
  33.  
  34.  
  35.    Remember, though, that the first computer designers tended to think in
  36. terms of fixed point fractions, not integers.  This thinking pervades
  37. the early papers on computer arithmetic from the 1940's.  In this case,
  38. your machine word has a binary point just to the right of the sign bit,
  39. and the formula for the value (in 2's complement form) is:
  40.  
  41.   V = -b[0] + Sum( b[i]*2**(-i) )
  42.  
  43. To make this work, you number your bits like this:
  44.  
  45.   0 1 2 3 ...
  46.  
  47.  
  48. Summary:  There is a good argument for little-endian bit numbering when
  49. you are thinking mostly in terms of integers, and there is a good argument
  50. for big-endian bit numbering when you are thinking mostly in terms of
  51. fixed point fractions.
  52.  
  53.  
  54.    Back to the war of the endians, once you've decided how to number the
  55. bits in your word, it's awfully tempting to number the bytes in a word
  56. in the same way, particularly if you provide any instructions that address
  57. bits in a word directly.  It's true that it's all arbitrary, in some global
  58. sense, but documentation sure seems to make more sense when you number
  59. things in the same order for both bits and bytes.
  60.  
  61.    The least rational of all endian systems are the mixed endian messes
  62. where bytes are packed in orders such as 2301.  These seem to result from
  63. multiple generations of design, for example, where bytes in a sixteen bit
  64. word are little endian, but software for 32 bit operands grew up doing
  65. wordwise 16 bit work in a big endian style.  Then, when it came time to
  66. do 32 bit stuff in hardware, the data formats that were established by
  67. brain dead programmers become enshrined in hardware standards that will
  68. probably be with us for decades.
  69.  
  70.                     Doug Jones
  71.                     jones@cs.uiowa.edu
  72.