Sunday, April 9, 2023

From BIOS to Bootsect

When one powers on a PC  with am Intel microprocessor, the core starts up in real address mode.  Real mode has a 20-bit address space (x00000 to xFFFFF) which is 1MB long.  The core initializes the code segment (cs) register to xFFFF and the IP to x0000.  This makes the core to start executing the memory location xFFFF0 which is a location in the BIOS.

BIOS first set up the interrupt vector table (IVT) in the first 1KB of memory (x00000 to x003FF).  The BIOS data, which is 256B long, is placed next and after the IVT (from x00400 to x004FF).  The interrupt service routine is placed between x0E05B to x0FFFE (near the 56KB mark from start of memory).  The IVT is essential for BIOS to load the boot sector into memory.

IVT has 256 entries of 4-bytes each.  Two bytes for the segment register value and 2 bytes for the offset.

BIOS invokes INT 19h using IVT.  INT 19h load disk 0, track 0 and sector 1 into x07C00 (about 31KB from start of memory).  The sector is 512B long and is called Bootsect.


No comments: