So it suddenly occurs to me that I have a pending #assignment on by Operating Systems course. The assignment seems to be trivial: it is to create a bootloader which prints 'Hello World' on the console. Thought it would be interesting to understand this with some help from my mastodon folks
#university #operatingsystems #bootloader #nasm #assembly
PS: future me, if you happen to be reading this post after you have forgotten about this, you can thank me later.
Here is the code after a bit of good formatting(?) but at least its more readable. I have a lot of questions, but we will go through it line by line.
Re: [BITS 16], the most reasonable explanation I could find was that, when Intel introduced 32-bit CPU, it wanted to maintain backward compatibility with its older 16-bit bootloaders. So it made, the 32-bit mode of processing as a protected on-demand mode. Due to this convention, CPU's start processing the code in 16 bit mode, which then can transfer to 32 bits or 64 bits.
Meanwhile [ORG 0x7c00] also seems to be born out of convention. The BIOS loads the program to the RAM at 0000:7C00 before your program gets a chance to be executed. We _could_ ignore the ORG (aka origin), but your program will assume that its loaded at 0x0000 instead. (But you could choose to add 0x7c00 on every command if you would like to do the hardway).
I had been looking at what `MOV AH, 0x0E` means and I found this https://forum.osdev.org/viewtopic.php?f=13&t=31031, a 13 year old had been trying to make a bootloader. wow I feel so old.
For our #assignment, we _have_ to use #VirtualBox to run them, and create screenshots of the output of the same.
Looks like we have to choose "Floppy" storage type and choose the boot.img which we created earlier.
After several hours of debugging and a hundred open tabs, I present: Hello World in a Bootloader.
I wonder if I can submit this #mastodon thread as the assignment to my professor.
@srevinsaju Now you can read the source code of LILO, a PC MBR boooader that was used by Linux distros for several years before GRUB took over:
https://github.com/iamroot-x86-10/lilo-21.4.4/blob/master/first.S