3 ms·
It is clear that inline assembly is mostly needed in situations where the compiler doesn't implicitly know how to generate assembly instructions for your use ca
by afr0ck 5y ago
It is clear that inline assembly is mostly needed in situations where the compiler doesn't implicitly know how to generate assembly instructions for your use case.
For example, let's say an operating system's kernel has a procedure to disable cache snooping on the CPU. There is no way the compiler can implicitly generate this for you, except if a special built-in function is provided. But built-in functions do not exist for every case, and not for every supported CPU architecture.
In this example, every architecture-specific code of the kernel shall implement an interface named disable_cache_snooping() wrapping an inline assembly statement, invoking the underlying (x86, arm, mips, sparc, riscv, etc.) CPU's special instructions to disable cache snooping.