Search code examples
assemblybios

How is BIOS compiled


BIOS is written in Assembly language and a machine can only understand Binaries. BIOS is the first program which is loaded into memory when the system starts. What compiles BIOS to generate a binary file?


Solution

  • A BIOS engineer writes the BIOS in x86 assembly language, and then "compiles" it with a program like MASM or NASM.

    The resulting binary file is then burned into the Flash ROM chip (using a tool like this), which is then installed on the motherboard.

    When the PC is turned on, it begins executing the code from this flash chip, which initializes the hardware of the PC and then turns control over to the Operating System.

    Some comments on the above:

    • Newer UEFI BIOSes are written in C, except for the initial boot loader, which is still assembly.
    • The programming tool is usually only needed for initial programming of a blank flash chip (brand new motherboard on the assembly line). Once you have the system booted, you typically re-flash the BIOS chip using a software utility.
    • You do not always have to use a socketed flash programming tool. On newer motherboards, the chip may be surface-mounted directly, and is not socketed. In that case, there may be a programming connector on the motherboard to program the flash with a tool like this.