Advanced build guide for writing bootloader

For a computer architecture project, I want to write some boot code to make something simple (I was thinking of a snake game if it's not too complicated). I thought that writing a small bootloader to transfer control to C should not be too complicated, but I cannot find the exact information.

I am looking for some advanced x86 build guide that correctly describes protected mode (I still can’t say if I need to switch to it, my first instinct is that I don’t), how the computer boots up, reads from the keyboard and print to the screen.

I can write in the assembly and pass gcc to write small programs, I just need information to download and interact. Any information is appreciated, including books.

+4
source share
2 answers

I would recommend this website. You will find there (especially in the "Introduction" category) everything you need to know.

If you do not go into protected mode, you can use BIOS interrupts to print on the screen, read from the keyboard, etc. For example, interrupt 0x10, function 0x0e . If you want to use a program other than the bootloader, you will need to manually load it into memory. There are BIOS functions for reading from a hard disk (or a pendulum that emulates a hard disk), but you will have to process the file system yourself. Probably, in your case, the best solution would be to not use any and just an additional program written at a fixed address and force the bootloader to load it from this hard-coded position.

In addition, if you want to execute code compiled with gcc in real mode, you need to use the .code16gcc directive. This will make the gas genereate code executed in 16-bit real mode on 32-bit machines.

+3
source

There is a link here that came across a while ago, I thought it was interesting, so I added it to my favorites ... maybe this will help.

+2
source

Source: https://habr.com/ru/post/1399587/


All Articles