Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can't get my head around this.In the context of processor performance, how can the performance cost of instructions be compared? Why do instructions differ in their cost?
Posted

The "cost" of an instruction (lets stick with the lowest level, assembly) is the number of cycles it takes to complete that instruction. Some instructions take more cycles to accomplish than others, so therefore are more "expensive" to do.

Why do instructions differ in cost? Well depends on the amount of work they have to do. For example, an Add-Store has two operations, first it adds, then it stores. Other instructions may have 3 or 4, some may have to split 64 bit registers into 32 bit ones, etc. This all affects performance.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 19-Nov-13 13:59pm    
Right, a 5. See some more detail in my answer.
—SA
Because each instruction has few different forms (so each form can be considered as a separate instruction) and because different instructions use different number of CPU clock cycles. Another complication to this picture is the parallelism.

Please see:
http://en.wikipedia.org/wiki/CPU_clock[^].

See also:
http://en.wikipedia.org/wiki/Microcode[^],
http://en.wikipedia.org/wiki/Instruction_set[^],
http://en.wikipedia.org/wiki/Very_long_instruction_word[^],
http://en.wikipedia.org/wiki/MIMD[^].

—SA
 
Share this answer
 
v2
Comments
Ron Beyer 19-Nov-13 14:02pm    
Good expansion, +5. Simply studying the instruction set architecture for the target processor will give a lot of information about the cost. I remember having to compute cycle times by hand on an Motorola 68HC11 for projects, not fun :)
Sergey Alexandrovich Kryukov 19-Nov-13 15:24pm    
That's right. Thank you, Ron.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900