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