If you are writing an OS, I highly recommend the Pure64 bootloader from Return Infinity. It's much more straightforward to use compared to GRUB which imposes a lot of conventions on how you structure things.
httpss://github.com/ReturnInfinity/Pure64
httpss://github.com/ReturnInfinity/Pure64