I am looking for a program that counts the instructions executed when running a program. Or if there is a way to doit without using a program (which it seems like there should be) I would like to learn how to do this.
To be honest, the number of instructions executed is not especially interesting. Some instructions are preposterously slow compared to others, and most users are more interested in total execution time. What you probably need to know is how long your program is spending in its various functions?? (one obvious example: an op-code like rep movs can loop internally and move a massive chunk of memory in one go. It takes time, but it achieves the work of a lot of individual instructions).
It would, however, be fairly easy simply to count instructions. The 086 processors have a bit in their flag register called the trap bit, and if set, a particular interrupt is called after every single instruction. I don't know exactly how it behaves in protected mode. In old-fashioned 16-bit mode it used to be used by debuggers, because they could recover control after each instruction exectuted by another program. To count instructions you'd simply let the interrupt handler increment a counter each time the interrupt is called, before passing control back to the "counted" program.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.