Written in front

Writing a bootloader for a PC is much easier than we think. In fact, all you need to know is to know how the PC is booted. I saw a lot of similar articles on the Internet, saying a lot, some are very troublesome, I think that just writing a bootloader does not need to involve too much, know enough knowledge to actually write one out to see is The original purpose of many people, then this article is just right for you. The foothold of this article is short, simple, and you can understand it at a glance, but you don't know what to read and write a code that you can't even understand.

Now let's start the bootloader!

What is the bootloader?

In many articles, writing a bootloader is called developing a simple operating system. In fact, this is very one-sided. The bootloader is not an operating system, although the program can run on bare metal. The so-called boot program, intuitively speaking, is the first program executed by the BIOS when the system is powered on.

In order for the bootloader to function and let the machine recognize it, it must be placed in a special location. This location is the first sector of the disk (0-side 0 track 1 sector, note: no 0 sector), and one contains The sector of the bootloader is called the boot sector.

A legal boot sector (1) usually contains 512 bytes (of course, one sector is usually 512 bytes), (2) and ends with 0xAA55, which occupies two bytes of data. . (Note: The 0x prefix indicates that this is a hexadecimal number).

That is, if the boot sector is treated as a character array of BootSector[] (because one character, ie, char, just one byte), then the array has 512 elements, if declared in C language,

Char BootSector[512];

Then, a legitimate boot sector must end with 0xAA55, ie

BootSector[510] = 0x55;

BootSector[511] = 0xAA;

In addition to the end flag must meet the above requirements, although there is still 510 bytes of space in the middle, the execution code can be less than 510 bytes, and the remaining space can be filled with meaningless characters (usually 0x0).

JoyLED outdoor LED display is 50% lighter than traditional Led Advertising Panel, which saves transportation and labor cost. 

Patented light-blocking design  of JoyLED outdoor fixed LED screen prevents light leakage to the front. Led Display Modules support for front and rear maintenance. The handle design brings convenience to LED panel lifting. Great heat dissipation and IP65 protection grade for JoyLED Outdoor Fixed LED Display. Front Maitenance Illustration for LED display

Outdoor Fixed Led Display

Outdoor Fixed LED Display

Large Led Display,Led Video Panels,Led Display Board ,Led Fixed Outdoor Display

Shenzhen Joy LED Display Co., Ltd. , https://www.joe-led.com