The instruction pointer of the CPU, on boot, is hardcoded to the value 0xFFFFFFF0 i.e. the last 16 bytes of the 32-bit address space.
On boot, the BIOS copies itself to some address in memory.
So, the address contains 0xFFFFFFF0 contains a jump instruction to the place in memory where the BIOS has copied itself.Once the BIOS is loaded, it goes through the list of devices to check which are bootable: by checking the bytes 511 and 512 of the first sector of each device. If the value of those bytes is 0xAA55, that device is bootable.
Once a bootable device is found, copy the contents of the device's first sector into memory to the address 0x7c00. This address now contains the bootloader. Jump to this address and execute the code. The bootloader then loads the kernel at 0x100000.
Fun facts:
All x86 processors begin in a 16-bit mode called real mode. The bootloader switches to 32-bit protected mode by setting the lowest bit of CR0 register to 1.
0xb8000 is the start of video memory. This memory supports 25 lines, each line contains 80 ASCII characters. Each element here is of 2 bytes (1 byte for the ASCII character, 1 byte is the attribute byte like color). So, we can set the color of each character we want to display by writing bytes starting from this address.
Top comments (0)