I am learning how to make a bootloader from osdev. I\'m using NASM to assemble my code, and a x86 machine to run my bootloader. This is a little piece of code which prints a
Its 2018 and I have stumbled upon this same problem. Micheal's answers and comments seem to be the best solution yet. We don't live in a perfect world and that's just how it is. This is why I wanted to develop a BIOS when I started OS Dev. I hate to run someone else's code in my computer without examining it. But that's just too hard in case of Firmwares and BIOSes. It might even brick your PC if you mess with the BIOS without knowing what you're doing.
Anyway, I have just added this comment in case someone else stumbles upon this same problem later. I would seriously suggest to examine the source code and/or reverse engineer some already available bootloaders like GRUB, Windows Boot Manager, LILO etc. You can also download live USB linux distros for your PC, install it in a flash drive and look at the boot sector code in a Hex Editor and maybe even disassemble it.
This isn't exactly an answer to the question but its worth a mention. To make this more relevant all I can say is that I have reversed GRUB's code, as installed on Kali Linux USB bootable and it starts with a XOR BP, BP instruction.