tags:

views:

112

answers:

4

When computer is powered on: How does it know from which instruction it needs to start executing?

First its the BIOS program that needs to be executed. So, what exactly happens there? I want to know the process till OS is loaded.

+2  A: 

I think Wikipedia's article on Booting has more detail than you could possibly want.

aem
+3  A: 

It's very processor dependent, as you might expect.

In general, the processor hardware comes up in some default configuration, and then starts executing from a particular memory address. What happens after that is all up to software.

Usually the first instruction executed is a jump to bootloader software of some kind, which then prepares the hardware and loads the next software stage. Repeat that setup/load process as many times as you want and presto - you're in the OS!

Some processors are more configurable than others, and have hardware strapping options (or fuses in silicon) that can control some of the boot parameters. Others have built in ROM code that executes at power on or chip reset. Some chips have built in memory, others can set up external memory automatically, and still others require software to be loaded to perform even the most basic of bootstrapping tasks.

If you clarify your question a bit more, we might be able to fill in some more details about the specific process of a system you're interested in.

Carl Norum
A: 

Most CPUs have a hard-coded reset vector, which determines the address of the first instruction to be executed after a hardware reset. Think of this as the mother of all non-maskable interrupts.

Paul R
A: 

The two most popular options are

  • starting at a fixed address (often 0)

  • starting at an address which is stored in a fixed location (the reset vector)

It depends on the specific processor.

starblue