Solved

Execution time of assembly code

Posted on 2008-06-11
2
925 Views
Last Modified: 2012-06-22
Hi,
for some reason I need the time a piece of assembly code should need.
In the good old 8086 time the Intel Manual told how much time a single instruction need.

I have tried to read the Intel documentation to find the timing for the instructions of the instruction set But I was not able to find it.
Could someone can tell me how I can determine the time a pice of code should use?

Here is the code I want the timing for.
      mov      DWORD PTR _k$[ebp], 1000000            ; 000f4240H
      jmp      SHORT CheckCondition
Next:
      mov      eax, DWORD PTR _k$[ebp]
      sub      eax, 1
      mov      DWORD PTR _k$[ebp], eax
CheckCondition:
      cmp      DWORD PTR _k$[ebp], 0
      jle      SHORT LoopEnd
      jmp      SHORT Next
LoopEnd:

But I need an instruction How the timing can be calculated.
It is machine dependent and must run on different Intel CPU's

Thanks for the Help

Regards
Norbert
0
Comment
Question by:Norbert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 21767262
>> Could someone can tell me how I can determine the time a pice of code should use?

That is VERY complicated, if not impossible, since today's CPU's have a lot of performance optimizations in them (pipelines, superscalar CPU's, instruction caches, branch prediction, speculative execution, out-of-order execution, etc.), so the timing will highly depend on the CPU, but also on the current state of the CPU (ie. based on the instructions before and after the instruction to be measured).


If you are just looking for the instruction execution latencies, you can find those in the technical documents. For example, for the AMD64 processors, you have these documents :

    "Software Optimization Guide for AMD64 Processors" (http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25112.PDF) -> appendix C lists the instruction latencies

    "AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions" (http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24594.pdf) -> gives more detailed information about the instructions

I gave that CPU as an example, because that's the one I'm using ;) Similar documents can be found for other CPU's, and I'm sure Intel also has these kind of documents with this information.
0
 
LVL 3

Author Comment

by:Norbert
ID: 21814013
The good old times are gone. so it is no more possible to determine exact what time is theoretical used for a code sequence. But you gave me some hints where I can look and I Found also some answers

Thanks
Regards
Norbert
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question