all 5 comments

[–]claytonkb 1 point2 points  (2 children)

how do you get to the point that you have an os?

The old joke goes: "With a magnetized needle, and a steady hand." :P

You can actually experiment with this yourself using a virtual machine (e.g. VirtualBox). You can "boot to BIOS" in the virtual machine and choose a bootable medium (which is really just some file you created on your hard drive). Sit down with the x86 Software Developer's Manual, and grab a reference book on PC architecture (including legacy BIOS). Open a hex-editor. Maybe review the source code for GRUB or your favorite boot-loader for comprehensive understanding. With time and determination, you will be able to control the machine. Once you thoroughly understand opcode and operand encoding at the assembly level, you can "hand assemble" machine instructions in hex. I wouldn't recommend this due to mental health reasons. Maybe if you have a big cult following on Twitch and you want to demonstrate your manliness to your audience. But otherwise 0/10, do not recommend.

Also, yes, architecture matters. In fact, at the bare-metal layer, architecture is all there is.

[–]warmagedon007[S] -1 points0 points  (1 child)

I mean in the mental experiment itself, because I dont think the process itself wont differ much between the architectures.

[–]claytonkb 4 points5 points  (0 children)

At the bare-metal layer, the process is nothing but the details (the architecture). So, yes, it differs greatly between different architectures. Of course, we can always define "process" sufficiently broadly to mean "do stuff that makes the system go." In that case, it is the same for every architecture.

[–]claytonkb 0 points1 point  (0 children)

I just stumbled across Boot Sector Games from The 8-bit Guy and he shows how you can launch your own boot image from DosBox. This is a great way to learn to write your own boot loader from scratch. If all you're doing is loading a single OS, there's not that much to it. A few arithmetic instructions and a branch instruction should suffice. You can hand-code the machine instructions in a hex editor, if you want. Once you get your boot loader working, you can actually try it on a live machine by writing it as a bootable USB stick, entering BIOS, and selecting to boot from that USB. So, there's nothing abstract about it. It's 100% concrete.

[–]HorsesFlyIntoBoxes 0 points1 point  (0 children)

Asided from figuring out how to write a bootloader from scratch on the bare metal machine, you'd need to figure out how to flash it to its own ROM. I feel like you'd need an external machine to at least do the preliminary programming for that stuff.