Need help with C bootloader
Posted: Mon Jun 16, 2014 3:03 pm
The last 3 days I searched the web for articles about writing a bootloader in C, because it was getting boring to write code in
Assembly.
All I came up so far was this (http://dc0d32.blogspot.in/2010/06/real- ... iting.html).
I tried the first example but I couldn't get it working correctly.
First error occours at
while using the linker.
I was able to fix that by changing "main" to "_main" cause I read somewhere that in the process of building function's names get prefixed
with a "_" (Is that right?). After this everything ran without any troubles, but if I run it in Virtual Box nothing is displayed on screen.
Also of couse I searched the first on the internet and added a return call to it, but that didn't solve the problem either.
Btw: I use DJGPP on Windows XP x86 for compiling my code
Assembly.
All I came up so far was this (http://dc0d32.blogspot.in/2010/06/real- ... iting.html).
I tried the first example but I couldn't get it working correctly.
Code: Select all
__asm__(".code16gcc\n");
__asm__ ("jmpl $0, $main\n");
#define __NOINLINE __attribute__((noinline))
#define __REGPARM __attribute__ ((regparm(3)))
#define __NORETURN __attribute__((noreturn))
void __NOINLINE __REGPARM print(const char *s){
while(*s){
__asm__ __volatile__ ("int $0x10" : : "a"(0x0E00 | *s), "b"(7));
s++;
}
}
void __NORETURN main(){
print("woo hoo!\r\n:)");
while(1);
}
Code: Select all
__asm__ ("jmpl $0, $main\n");
//Error: bootloader.o:bootloader.c:(.text+0x2): undefined reference to 'main'
I was able to fix that by changing "main" to "_main" cause I read somewhere that in the process of building function's names get prefixed
with a "_" (Is that right?). After this everything ran without any troubles, but if I run it in Virtual Box nothing is displayed on screen.
Also of couse I searched the first on the internet and added a return call to it, but that didn't solve the problem either.
Btw: I use DJGPP on Windows XP x86 for compiling my code