I'm trying to load a GRUB module as a very simple program. However, when calling it I get an INT6 "Invalid Opcode" exception. Everything seems in order, however, and I don't know what I'm doing wrong. My code is below.
Here is the "program" which I compile into a flat binary:
Code: Select all
mov eax, 0xDEADBEEF
loop:
jmp loop
Code: Select all
extern kmain
push ebx
call kmain
Code: Select all
#include "multiboot.h"
//including other stuff, functions, etc.
int kmain(unsigned int ebx){
//load gdt, setup interrupts, etc.
puts("Hello, world!");
multiboot_info_t *mb_info = (multiboot_info_t *)ebx;
void (*start_program)();
unsigned int module_address = mb_info->mods_addr;
unsigned int module_count = mb_info->mods_count;
if (module_count == 1){
start_program = (void *)module_address;
start_program();
}
return 0;
}
Any help is appreciated. Thanks!