FUNDAMENTALS & SYSTEM ARCHITECTURE
Discipline: Computer Science & Engineering | Module 01: Detailed Course Notes |
Standard: ISO/IEC 9899 (C11)
1. Historical Context & Architectural Design Philosophy
Developed by Dennis Ritchie at AT&T Bell Laboratories in 1972, the C programming
language was engineered to implement the UNIX operating system. C is classified as a
general-purpose, procedural, statically typed, compiled language that provides low-
level deterministic access to system memory while maintaining hardware portability.
Core Architectural Characteristics
Deterministic Memory Control: Supports direct manipulation of physical and virtual
memory addresses through pointers and explicit byte-level allocation.
Minimal Runtime Overhead: Lacks automatic garbage collection or runtime type
reflection, producing compact machine binaries suitable for operating system kernels,
device drivers, and embedded firmware.
Structured Procedural Paradigm: Enforces modular program decomposition via
functions, block-level lexical scoping, and structured control constructs.
2. The Four-Stage Compilation & Build Pipeline
Translating human-readable source code into an operating-system-executable binary
requires four sequential software tools invoked automatically by compiler drivers such as
gcc or clang :
±-----------------+ ±-----------------+ ±-----------------+ ±-----------------+
| Source File | | Expanded Code | | Assembly Code | | Object File |
| (main.c) | --> | (main.i) | --> | (main.s) | --> | (main.o) |
±-----------------+ ±-----------------+ ±-----------------+ ±-----------------+
||||
[1. Preprocessor] [2. Compiler] [3. Assembler] [4. Linker]
Expands macros & Syntax/semantic Translates ASM Resolves symbols &
header files checks -> ASM to machine code links libc -> .exe
Detailed Stage Breakdown
Stage I — Preprocessing ( .c .i ): The C Preprocessor ( cpp ) executes textual
transformations before syntax analysis begins. It strips all single-line ( // ) and multi-line
( /* */ ) comments, recursively inserts header file contents ( #include ), performs macro
text substitution ( #define ), and evaluates conditional compilation directives ( #ifdef ,
,#endif ).
Stage II — Compilation ( .i .s ): The compiler front-end performs lexical
tokenization, constructs an Abstract Syntax Tree (AST), enforces static type-checking
rules, and emits target-architecture-specific Assembly Language instructions (e.g., x86-
64 or ARM64).
Stage III — Assembly ( .s .o ): The Assembler ( as ) converts symbolic assembly
mnemonics into relocatable binary machine opcodes packaged inside an Object File (ELF
format on Linux, COFF/PE on Windows).
Stage IV — Linking ( .o Executable): The Linker ( ld ) merges multiple object files,
resolves external function references (such as printf ) against the C Standard Library
( libc ), and assigns final virtual memory addresses to generate the executable binary.
3. Lexical Elements: Tokens, Keywords & Identifiers
During lexical analysis, the compiler decomposes source text into six fundamental atomic
units known as Tokens:
Keywords: Reserved words with predefined syntactic meanings (32 in ANSI C89; 44 in
C11), such as int , return , const , volatile , sizeof , and struct .
Identifiers: User-defined names assigned to variables, functions, arrays, and structures.
Constants (Literals): Immutable data values hardcoded in source text (e.g., 42 ,
3.14159 , ‘Z’ , “System” ).
String Literals: Contiguous sequences of characters enclosed in double quotes,
automatically terminated by a null character ( ‘\0’ ).
Operators: Symbols instructing the CPU to perform arithmetic, logical, bitwise, or
memory operations.
Punctuators (Separators): Syntactic delimiters including semicolons ( ; ), braces ( {} ),
brackets ( [] ), and parentheses ( () ).
Lexical Rules for Valid Identifiers:
Must begin exclusively with an alphabetic character ( A–Z , a–z ) or an
underscore ( _ ).
Subsequent characters may comprise letters, digits ( 0–9 ), or underscores;
whitespace and special symbols ( @ , $ , - ) are strictly prohibited.
C is strictly case-sensitive: totalCount , TotalCount , and TOTALCOUNT
represent three distinct memory identifiers.
4. Primitive Data Types, Modifiers & Internal Representation
A variable declaration reserves a contiguous block of Random Access Memory (RAM) and
binds a symbolic name to its starting byte address.
4.1 Standard Data Types & Type Modifiers (64-Bit Architecture)
Type modifiers ( signed , unsigned , short , long ) alter the storage width and