Two posts ago I explained why 0x55aa is the boot signature. But how do we actually create a bootloader? Well, we can do it in only 3 lines. We are going to be using Assembly x86. Assembly is the most basic language before machine code. First, we jump(jmp) to the current address(represented by a dollar sign): jmp $ Then we are going to fill the rest 510 bytes with 0. We will do this using two dollar signs($$), which means the start of the section,which would be the start of the code. As we saw in the other post, we need to fill the 510 bytes using db(define byte) and reserve the last two to fill with 0x55aa. Our code would look like this: jmp $ times 510-($-$$) db 0 Lastly, we fill the last two bytes with 0x55aa jmp $ times 510-($-$$) db 0 db 0x55, 0xaa If we compile this with the NASM and use an emulator like QEMU to run it, we will see that it loads perfectly. But that isn't very interesting, is it? In the next post, we will print something to the screen.
Why is this the name of this blog? What does it mean? Today we are going to be answering those questions. 55aa is the "boot signature" for the bootsector. This can be confusing. A boot sector is the part of a persistent data storage device(ex. a hard disk) which contains machine code to be loaded to the RAM(Random Access Memory) and then executed. But how does the computer know that it is a bootsector? That's where the boot signature comes in. The computer only checks the first 512 bytes of the storage, and if it ends in "55aa", it recognizes it as a boot sector, so it moves it to the RAM and executes it. But why "55aa" and not any other number? Well, the answer is very simple. "55aa" is an hexadecimal number(that's why we write "0x" at the start, to tell the computer that we are writing a number in hex), and in decimal it is 21 930. And in binary it's 0101 0101 1010 1010(again, before that we must put 0b, so the computer r...
Have you ever wondered why computer bugs are called that way? Some of you may already know it, but it turns out that it was an actual bug! In 1947, some computer scientists on Harvard opened the Mark II computer when it was delivering consistent errors.When they opened it, they found a moth inside that had broken some components of the computer. One of the computer scientists was Grace Hopper, who made the incident famous and was one of the first computer programmers. Since then, when there was something wrong with a computer, we say it has a "bug".
Comments
Post a Comment