Posted 17 September 2010 - 05:40 AM
Well, that varies between types of computer and operating system. In principle, bootstrap code in the boot sector of the system's boot device (eg hard drive) determines what executable runs first.
With an IBM compatible, the CPU must start in Real Mode, whereas a modern operating system requires Protected Mode, so for an OS like Windows the first executable that runs is a Real Mode Loader. It starts in Real Mode, switches the CPU to Protected Mode and commences loading the OS kernel. In 32-bit NT-based Windows it's called ntldr.exe, but I haven't investigated if a 64-bit OS is structured in exactly the same way, just with 64-bit executables.
Top 5 things that never get done: