You will find some assembly-level code in the /arch subtree.
Some of the code is pure-assembler, such as the so-called "trampoline" which hands control from the boot-loader to the kernel. Much of it takes the form of functions with asm {...} blocks which are used when specific machine instructions must be issued on a particular architecture.
Since Linux runs on well over twenty different architectures – "from mainframes to microwave ovens" – the use of assembly code is confined to these areas. Also notice how it is used to implement functions which are called by non-assembly code, and how the actual use of assembly code is minimized. (Because "compilers write better code than we do.")
The source-code sometimes uses macros, which are implemented on some architectures and no-ops on others.
Unlike "user-land" source code, the kernel code does not use any sort of "runtime library." (There is no glibc.)
Today's microprocessors aren't engineered to be programmed "by hand." They're engineered to accept object-code that has been produced by a compiler. Chip designers work closely with compiler designers, and also produce their own compilers. Assembly is now used only where there is no other alternative – where you are obliged to specify exactly what the CPU is to do. At all other times, "the compiler will produce better object-code than you would."
Last edited by sundialsvcs; 02-07-2018 at 12:12 PM.
|