The basic indivisible unit in which all executable code resides, from the C source code to the binary executable, is typically referred to as a "function" or "procedure" at the source code level. During the compilation and linking process, these functions are transformed into "machine code instructions" that the CPU executes.
Here's a breakdown of the stages:
-
C Source Code: The smallest unit is a function, which is a collection of statements that perform a specific task. Functions can be called from other parts of the program and can also call other functions.
-
Compilation: When the C source code is compiled, the compiler translates functions into assembly code. The smallest unit at this stage is an assembly instruction. The compiler optimizes the code and may inline functions, unroll loops, or perform other optimizations.
-
Assembly: The assembler converts the assembly instructions into machine code. At this point, the smallest unit is a machine code instruction, which is directly executable by the CPU.
-
Linking: The linker combines all the object files (which contain machine code) produced by the compiler into a single executable file. In this file, the code is organized into sections, such as the text section for the executable code and the data sections for initialized and uninitialized data. The machine code instructions remain the smallest units of executable code.
-
Binary Executable: The final binary executable file is made up of machine code instructions, which are the basic indivisible units of execution. The operating system's loader loads this binary into memory, and the CPU executes the machine code instructions.
In summary, while functions are the smallest logical units in the source code, the actual smallest indivisible unit of executable code that the CPU processes is a machine code instruction.