In general cases, the sequence of instructions processed by the processor is contiguous (sequential execution).
The exception control flow provides a jump to instructions, part of which is implemented by the hardware, and partly by the operating system.
Exception handling
at system startup, the operating system allocates and initializes a jump table called the exception table:
The code that will find and execute the corresponding exception handler from the Jump table when the exception is triggered (so-called kernel-state code?):
System calls
Each system call is an exception, and an exception is triggered when a system call function in the C library is called.
In a IA32 system, a system call is provided through a trap instruction called an int 0x80 (exception number).
All Linux system calls are passed through registers.
Here is an example of a system call
int Main () { write (1"Hello, world\n"); Exit (0); }
The corresponding assembly code
Main: movl $4,%eax system call number MOVL $,%ebx file descriptor movl $string,%ecx "Hello, world\n" movl $len,%edx length int $0x80 ...
Csapp: Exception Control Flow