|
-
Oct 28th, 2005, 12:32 PM
#1
Questions about code efficiency
1. Does anyone have a list of opcodes along with the number of clock cycles they use up?
2. When comparing speeds of code, is it enough to just compare the number of clock cycles that each instruction takes? Or is it more complex than that (I'm talking about instruction-by-instruction comparison at the moment, not looping or anything I realise that makes things infinitely more complex).
3. For things like shifting does shifting by 25 bits (for example) take the same time as shifting by 1 bit? Or is it 25 times longer?
I'm used to High level languages as you can probably tell and I'm finding it difficult to comprehend the speed of ASM.
("Damn this thing its not working, it just returns immediately!! Oh wait its finished already, bloody hell" )
I don't live here any more.
-
Nov 9th, 2005, 07:22 AM
#2
Addicted Member
Re: Questions about code efficiency
1. Does anyone have a list of opcodes along with the number of clock cycles they use up?
I do.....
http://www.agner.org/assem/pentopt.pdf
http://www.intel.com/design/pentium4...tm#em64_doc_ch
These are everything you need...unless you want the AMD versions...which you can find on their website.
2. When comparing speeds of code, is it enough to just compare the number of clock cycles that each instruction takes? Or is it more complex than that (I'm talking about instruction-by-instruction comparison at the moment, not looping or anything I realise that makes things infinitely more complex).
More complex. You have cache misses, memory reads/writes, dependencies etc. (Read pentopt.pdf)
3. For things like shifting does shifting by 25 bits (for example) take the same time as shifting by 1 bit? Or is it 25 times longer?
Same speed.
e.g.
shr eax, 5 = shr eax, 25
however
rol, rot might be different i believe.
So it depends on the instruction. but generally they are the same provided that the type of operand is the same e.g. add eax, [mem] will be slower than add eax, ebx
-
Nov 9th, 2005, 08:27 AM
#3
Re: Questions about code efficiency
Nice one thanks (again )
I don't live here any more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|