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.
@srevinsaju Which assembler are you using? I've never seen square brackets for assembler.dorextives. The traditional UNIX as as.wellcas gas uses . to introduce directives: https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_7.html
@codewiz I am using the nasm assembler, it was the one specified in our university study material.
@srevinsaju Looks like it's still actively developed:
https://github.com/netwide-assembler/nasm
I never used nasm because it came from the DOS/Windows world and uses the Intel syntax (as opposed to the AT&T syntax, which is standard in UNIX/Linux toolchains).
@srevinsaju Here's some Motorola 68000 #asm I wrote long ago for the #Amiga:
https://www.codewiz.org/projects/amiga/XModule/XModuleSrc/Startup.asm
How does it look compared to 8086 asm?
This is part my first open source project, a GUI tracker and module format converter.
I never managed to finish it, and now it seems silly to spend time rewriting the entire C startup code in assembly, when it's not at all performance critical.
But that's how kids learn!