2 ms·
And cache management, thread switching optimization/prioritization, and so on. If a CPU were to ONLY do the instructions that were written in the assembly code
by trashtester 4y ago
And cache management, thread switching optimization/prioritization, and so on.
If a CPU were to ONLY do the instructions that were written in the assembly code, the code could be maybe 5-10 times slower when using cached memory and 100x slower if accessing RAM constantly.
And this is part of the reason why it's hard to write assembly that is faster than a well optimized C/C++ program. The C compiler "knows" (to some extent) what the machine code leads to at the hardware level, and will often create machine code that is more liklely to allow the CPU to reap all such advantages in a way many assembly programmers wouldn't know about or think of.