Hi, I have written a program with NASM . It can run in DOS.
I want to use GRUB4DOS to load that program into memory.
Here is my command in GRUB:
root (fd0) (1)
kernel /mykernel.bin (2)
After line (2) execute, the grub told me this information:
Error 14: Invalid or unsupported executable format.
The head of my program is like this:
org 0100h
jmp START_REALMODE
As you see, I build this program to COM format.Is there anything should change when I want to build a binary file?
I don't know how to solve this problem. Please help me.
How to build a binary with nasm
There is nothing wrong with the COM-format, as long as your bootloader supports it. But I Grub doesn't support it. Grub needs additional info where to load it in memory. In most cases this information is included in the executable format, many Grub-users use ELF-format.
This topic is imho not needed when you read the manuals of Grub and Nasm.
This topic is imho not needed when you read the manuals of Grub and Nasm.
Re: How to build a binary with nasm
Hi,
All grub4dos is, apparently, is a slightly different implementation of GNU GRUB, with a few tweaks here and there. If you wish to use the 'kernel' command, you must provide a kernel which is either in ELF format (because GRUB can read ELF executables itself) or have a multiboot header, more information on which can be found here and here.
It's the lack of multiboot header that causes grub to fail.
Hope this helps,
James
I think you're slightly mistaken about a few things. You say that your program can run in DOS - does that mean that it relies on DOS functionality? if so, you won't be able to run it without DOS loaded first, and grub4dos doesn't do that (I've just looked at its wiki page).huxuelei wrote:Hi, I have written a program with NASM . It can run in DOS.
I want to use GRUB4DOS to load that program into memory.
Here is my command in GRUB:
root (fd0) (1)
kernel /mykernel.bin (2)
After line (2) execute, the grub told me this information:
Error 14: Invalid or unsupported executable format.
The head of my program is like this:
org 0100h
jmp START_REALMODE
As you see, I build this program to COM format.Is there anything should change when I want to build a binary file?
I don't know how to solve this problem. Please help me.
All grub4dos is, apparently, is a slightly different implementation of GNU GRUB, with a few tweaks here and there. If you wish to use the 'kernel' command, you must provide a kernel which is either in ELF format (because GRUB can read ELF executables itself) or have a multiboot header, more information on which can be found here and here.
It's the lack of multiboot header that causes grub to fail.
Hope this helps,
James