home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19430 < prev    next >
Encoding:
Text File  |  1993-01-08  |  2.6 KB  |  63 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Problem with string processing.
  5. Message-ID: <1993Jan8.174749.10707@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <MCGLK.93Jan5005833@yang.cpac.washington.edu> <811@ulogic.UUCP> <1993Jan6.162841.5570@taumet.com> <823@ulogic.UUCP>
  8. Distribution: usa
  9. Date: Fri, 8 Jan 1993 17:47:49 GMT
  10. Lines: 51
  11.  
  12. hartman@ulogic.UUCP (Richard M. Hartman) writes:
  13.  
  14. >What I was after was the rough equivilent difference between (Intel)
  15.  
  16. >    MOVSW    src,dst
  17.  
  18. >and a loop w/ 
  19.  
  20. >    MOV ax,src 
  21. >    MOV dstax
  22.  
  23. >(so sue me if my assembly is wrong...)  The thing is that, yes
  24. >each byte does have to get moved, but the one instruction moves
  25. >'em a heck of a lot quicker than the loop of separate instructions.
  26.  
  27. >... if the CPU "knows" how to do this in microcode, then you don't have to
  28. >waste CPU time loading all those instructions in the loop
  29. >over and over again, you just have to load the data.
  30.  
  31. This is the CISC vs RISC argument.  For a given machine it is likely
  32. that the single instruction, if available, will execute more quickly
  33. than an equivalent loop of simpler instructions.  The argument arises
  34. in comparing different machines.
  35.  
  36. If a machine has many instructions and complicated instructions, then
  37. instruction processing is complicated.  All instructions are affected
  38. by the requirement to handle complicated instructions, and simple
  39. instructions take longer than they otherwise would.  The string search
  40. instruction may execute relatively rapidly, but all the simple
  41. instructions execute relatively slowly.  If your entire program
  42. consisted only of searching strings for characters, you might have a
  43. big win.  Real programs do lots of other things too (like what you do
  44. when you find what you were searching for) and the overall performance
  45. may be worse.  Please note:  "MAY be".
  46.  
  47. A machine with a simple instruction set may be able to execute
  48. individual instructions so rapidly that it outweighs the cost of
  49. needing many more instructions.  Maybe a RISC machine takes a little
  50. longer to locate a character in a string, and maybe not.  Overall
  51. performance on complete programs may be better.
  52.  
  53. Going back to the single-machine case, the presence of a complicated
  54. instruction doesn't always mean a performance win.  A block-move
  55. instruction may significantly outperform a tight loop to do the move.
  56. But the block-move may require setup and use of special registers,
  57. displacing other parameters.  By the time you do the setup and restore
  58. displaced registers, you may have lost any advantage offered by the
  59. special instructon.
  60. -- 
  61.  
  62. Steve Clamage, TauMetric Corp, steve@taumet.com
  63.