The advantages of assembly languages when compared to the high level languages are as follows;
1. Debugging and verifying: Looking at compiler-generated assembly code or the disassembly window in a debugger is useful for finding errors and for checking how well a compiler optimizes a particular piece of code.
2. Making compilers: Understanding assembly coding techniques is necessary for making compilers, debuggers and other development tools.
3. Embedded systems: Small embedded systems have fewer resources than PCs and mainframes. Assembly programming can be necessary for optimizing code for speed or size in small embedded systems.
4. Hardware drivers and system code: Accessing hardware, system control registers etc. may sometimes be difficult or impossible with high level code.
5. Accessing instructions that are not accessible from high level language: Certain assembly instructions have no high-level language equivalent.
6. Self-modifying code: Self-modifying code is generally not profitable because it interferes with efficient code caching. It may, however, be advantageous for example to include a small compiler in math programs where a user-defined function has to be calculated many times.
7. Optimizing code for size: Storage space and memory is so cheap nowadays that it is not worth the effort to use assembly language for reducing code size. However, cache size is still such a critical resource that it may be useful in some cases to optimize a critical piece of code for size in order to make it fit into the code cache.
8. Optimizing code for speed: Modern C++ compilers generally optimize code quite well in most cases. But there are still many cases where compilers perform poorly and where dramatic increases in speed can be achieved by careful assembly programming.
9. Function libraries: The total benefit of optimizing code is higher in function libraries that are used by many programmers.
10. Making function libraries compatible with multiple compilers and operating systems: It is possible to make library functions with multiple entries that are compatible with different compilers and different operating systems. This requires assembly programming.