How long does it take to complete each machine language instruction?

Do operations like typing, reading, moving, and comparing do anyway to perform?

If not: is there a way to find out how long.

Is there any name for what I mean, some processor speed of a certain type for executing various instructions in assembly language (moving, reading, etc.).

+4
source share
4 answers

The key conditions that you are probably looking for are:

  • Learning delay
  • Program bandwidth

This should be easy for Google. But basically instructions execute a certain number of cycles to execute (latency). But you can often execute several of them at the same time (bandwidth).

Do operations such as typing, reading, moving, and comparing do all this time?

In general, no. Different instructions have different delays and bandwidth. For example, adding is usually much faster than dividing.


If you are interested in the actual values ​​of the various assembly instructions on modern processors, you can look at the Agner Fog tables .


This suggests that there are gazillion other factors affecting computer performance.
Most of them are perhaps more important than command delays / bandwidths:

  • Cache
  • Memory
  • Disk
  • Bloat (seems to be big ...: D)
  • etc. the list goes on and on ...
+8
source

Pipelining and caches, and the processor itself is no longer the main bottleneck, made two questions to your question. Firstly, the processor today usually executes one instruction per clock cycle, and secondly, it may take many (tens to hundreds) hours to supply the processor. More modern processors, even if their instruction sets are out of date, rarely mention clock execution because it is one clock cycle and the β€œreal” execution speed is too complicated to describe.

The cache and pipeline try to allow the processor to work with one instruction per clock frequency, but, for example, reading from memory, must wait for a response in order to return. If this element is not in the cache, it can be hundreds of clock cycles, because it will need to read several places to fill the line in the cache, and then a few more hours to get them through the caches back to the processor.

Now, if you return in time or now, but to the world of microcontrollers, for example, or to another system in which the memory system can be responsible for one clock cycle or at least a very deterministic number (say, two hours for eeprom and one for ram, this kind of thing), then you can very easily calculate the exact number of hours. Such processors often publish a cycle table per instruction. For example, for two teams, for example, it would be two hours to retrieve a command, and then another measure to read, at least 3 measures. some actually take more than one measure to execute so that it is added as well.

I highly recommend finding a (used) copy of Zen of Assembly Language by Michael Abrash. It was dated when she left, but still important work. learning to juggle the relatively simple 8088/86 was tough enough, today's x86 and other systems are a bit more complicated.

If you run windows or linux or something like this, trying to figure out your code, be sure to get you where you want. add or remove nop, as a result of which the code will be aligned in memory by as many as bytes can greatly affect the performance of the remainder of the code, which has not changed, than its location in ram. As a simple example of understanding the complex nature of the problem.

Which processor or system are you interested in? The stm32f4 detection board, about $ 20, contains an ARM processor (cortex-m) with command and data caches. This has the complexities of a larger system, but at the same time simple enough (relative to a larger system) to be able to control experiments.

If you are familiar with the pic world microchip, they often count loops to perform precision delays between events. A very deterministic environment (until you use interrupts).

+3
source

How fast is each assembly language instruction? Do operations like typing, reading, moving, and comparing do anyway to perform?

You will find this information in the CPU processor assembly guide from the CPU manufacturer (e.g. Intel). Each processor structure usually has a page or two, and it tells you how many β€œloops” it will take to complete. It will define "loops" elsewhere. Instructions can be executed at different points in time, depending on what is given to them. for example, a conditional jump may or may not jump. Multiplying by zero can (I guess) be faster than multiplying by 7.

+2
source

The answer is MIPS. or IPS millions of instructions per second. Since you are talking about embedded systems.

0
source

Source: https://habr.com/ru/post/1392160/


All Articles