BareBones error?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Candamir

BareBones error?

Post by Candamir »

I've found this error in BareBones (error?) from the FAQ:

Code: Select all

push eax                ; Multiboot magic number
push ebx                ; Multiboot info structure
Then, I adapt main, etc.
But when I check the GRUB example files, they push ebx first and then eax...

Really, if it's a stack, it would be more logical to first put the last argument (in the c function declaration), but as it's the official example...

Also, when I tried to run this method first thing in my kernel:

Code: Select all

/** Checks the magic flag.
 * The header constant is defined in multiboot.h
 */

void check_magic(unsigned int magic)
{
   if (magic == MULTIBOOT_HEADER_MAGIC)
   {
      return;
   }
   else
   {
      panic("Multiboot header magic flag not correct!");
   }
}
It seemingly invokes the kernel panic method (I actually don't know, because I did run it on hardware and not on BOCHS) and reset. (The kernel panic method resets the computer after waiting a moment, but as the timer isn't yet set up at that moment... I think I'll try it in BOCHS later...

But anyway, even the GNU Assembler example of BareBones first pushes eax and the GRUB reference first ebx; and both are in gas (I first thought things were different on NASM)...

Could anyone explain, please...
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:BareBones error?

Post by Colonel Kernel »

In the GRUB example, the magic number is the first parameter to main, so they push it last. In the BareBones example, the magic number is the last parameter to main, so they push it first. Be consistent, and all should be well.
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
Candamir

Re:BareBones error?

Post by Candamir »

Oops. But anyway, I think the mistake is that in file multiboot.h, there are two constants: MULTIBOOT_HEADER_MAGIC and MULTIBOOT_BOOTLOADER_MAGIC, and I think I used the wrong one...
Post Reply