Page 1 of 1

Bare Bones tutorial on GRUB

Posted: Wed Feb 27, 2008 12:27 am
by birie
Aloha all,
I was just working with the barebones tutorial on creating a correct multiboot elf kernel. In the tutorial it pushes eax then ebx. In the multiboot spec (0.6.95) the first parameter that is passed is ebx then eax. I was just wondering if this was intentional and there is something I am missing or if it was just based of off an older multiboot spec.
Thanks,
Bryce

Posted: Wed Feb 27, 2008 12:36 am
by codemastersnake
I don't know about the tutorial but you should always stick to the official documentations.

Posted: Wed Feb 27, 2008 12:59 am
by Solar
Hmmmm... I know I got the order wrong once, but I thought I corrected that in my code before I wrote that tutorial. It might well be that bug survived; can you double-check this, i.e. check which way around actually leads to the correct results?

Posted: Wed Feb 27, 2008 4:27 am
by birie
Ebx then eax produces correct results for me. I suppose it all depends on how you write your c function. I copied the kernel.c code from the multiboot spec website and needed to swap.

Re: Bare Bones tutorial on GRUB

Posted: Wed Feb 27, 2008 6:17 am
by os.hacker64
birie wrote:Aloha all,
I was just working with the barebones tutorial on creating a correct multiboot elf kernel. In the tutorial it pushes eax then ebx. In the multiboot spec (0.6.95) the first parameter that is passed is ebx then eax. I was just wondering if this was intentional and there is something I am missing or if it was just based of off an older multiboot spec.
Thanks,
Bryce
A brother Hawaiian!

Posted: Wed Feb 27, 2008 6:45 am
by Solar
birie wrote:I suppose it all depends on how you write your c function. I copied the kernel.c code from the multiboot spec website and needed to swap.
Aaaahhhhh... that explains it, then.

Multiboot: kernel.c

Code: Select all

void cmain (unsigned long magic, unsigned long addr)
BareBones: main.c

Code: Select all

void main( void* mbd, unsigned int magic )
If the C function expects to pop the parameters the other way round, of course you have to push them the other way round, too.

This isn't a mistake either in the BareBones or the Multiboot docs, as there is no "right" way to put the parameters on the stack. You just tried to slice & dice code from two different sources, and got bitten by a difference in interface. ;-)

re:

Posted: Sun Mar 02, 2008 5:56 pm
by birie
Back to that old think before you post thing. (: I realized it just after I posted. Thanks for the response. And hello to all the hawaiian os devs.