home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / arch / 10585 < prev    next >
Encoding:
Text File  |  1992-11-10  |  3.4 KB  |  84 lines

  1. Newsgroups: comp.arch
  2. Path: sparky!uunet!think.com!spool.mu.edu!umn.edu!news.orst.edu!pmontgom
  3. From: pmontgom@math.orst.edu (Peter Montgomery)
  4. Subject: Re: register + register addressing
  5. Message-ID: <BxIFC5.BEr@news.orst.edu>
  6. Sender: usenet@news.orst.edu
  7. Nntp-Posting-Host: lab12.math.orst.edu
  8. Organization: Oregon State University Math Department
  9. References: <18938@ucdavis.ucdavis.edu> <endecotp.721329802@cs.man.ac.uk>
  10. Date: Tue, 10 Nov 1992 17:02:26 GMT
  11. Lines: 71
  12.  
  13. In article <endecotp.721329802@cs.man.ac.uk> endecotp@cs.man.ac.uk
  14. (PB Endecott (PhD SFurber)) writes:
  15. >
  16. >Although it's true that both register+offset and register+register modes
  17. >require an addition, you haven't allowed for the fact that an extra
  18. >register read has to take place.  Normally most microprocessors have two
  19. >read ports and one write port on the register file, which is exactly what
  20. >is required for three address arithmetic/logical operations.  When you
  21. >execute a store instruction, one read port is used for the data value, and
  22. >the other for the address register.
  23. >
  24.         ...
  25. >
  26. >Of course for a load, you do have two read ports available.  Would anyone
  27. >consider an architecture with non-symetrical addressing modes, where loads
  28. >can do register+constant or register+register, but stores can do
  29. >register+constant only?
  30. >
  31. >Another feature that some processors have and others don't is
  32. >auto-indexing.  During loads, this requires an extra write port (or an
  33. >extra cycle) to put the modified value back in the register; but during
  34. >stores the write port is not used for data.  So how about an architecture
  35. >with autoindexing for stores but not for loads ?
  36.  
  37.         The loops where I have found register+register indexing most useful
  38. are those resembling
  39.  
  40.         for I from 0 to N do
  41.             A(I) := B(I) + C(I)*D(I)
  42.         end for
  43.  
  44. All arrays have the same data type, say 4 bytes per item.
  45. You initialize four registers with the addresses of A, B, C, D
  46. and put 4*I into another.  Only one increment (of 4*I) is needed
  47. per iteration, not four separate increments of &A(I), &B(I), &C(I),
  48. and &D(I).  When this code is nested inside another loop,
  49. the registers containing the base addresses won't need
  50. re-initialization every time, since they are not modified.
  51.  
  52.         The drawback is less freedom in the scheduling
  53. of instructions, since the increment of 4*I and the compare
  54. of 4*I to 4*N must wait until after the main computation
  55. of B(I) + C(I)*D(I).
  56.  
  57.         If one is more careful, we can overcome this hurdle and
  58. use register+register indexing only on loads.  The code would be
  59. (assuming array offsets start at 0):
  60.  
  61.         r1 = B-A+4
  62.         r2 = C-A+4
  63.         r3 = D-A+4
  64.         r4 = A-4        (will be A+4*(I-1)I)
  65.         r5 = A+4*N
  66.  
  67.         while (r4 < r5) do
  68.             temp := load(r1+r4) + load(r2+r4)*load(r3+r4)
  69.             increment r4, start compare against r5
  70.             store(r4) := temp
  71.         end while
  72.  
  73. (auto-indexing on store could also be used here)
  74.  
  75.         Register+register addressing is inadequate if one wants
  76. to load a datum and also its neighbor.  The MIPS R3000, for example,
  77. lacks double precision (8-byte) loads and stores.  Rather, the
  78. upper half of the datum and its lower half are loaded separately.
  79. If one half is loaded with register+register, the other half
  80. will need register+register+offset.
  81. -- 
  82.         Peter L. Montgomery              Internet: pmontgom@math.orst.edu
  83.         Dept. of Mathematics, Oregon State Univ, Corvallis, OR 97331-4605 USA
  84.