Page 1 of 1

bootloader, kernel with C++

Posted: Mon Jan 24, 2011 3:10 pm
by Cchedy
hi every one!
it's my first post in this forum:i m a begginner in the world od devlopment of os i m actually leaning how can i make my kernel with C++.
i have three file: loader.asm, kernel.cpp and video.cpp with his header video.h
there is my code:
loader.asm:

Code: Select all

[BITS 32]

[global start]
[extern _main]

start:
call _main
cli
hlt 
compile with nasm: nasm -f aout loader.asm -o loader.o
it make the loader.o
and with these two commands:
*gcc -c video.cpp -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions
*gcc -c kernel.cpp -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions
i get my file *.o this is there code:
kernel.cpp

Code: Select all

#include "video.h"

int main(void)
{
    Video v;
    v.write("bonjour cher utilisateur!");    
}
video.cpp

Code: Select all

#include "video.h"

Video::Video()
{        
      pos = 0;
      off = 0;             
      videomem = (unsigned short*) 0xb8000;
}
Video::~Video()
{
}
void Video::clear()
{
     unsigned int i;
     for(i=0;i<(80*25);i++)
     {
          videomem[i] = (unsigned char) "" | 0x700;
     }
     pos=0;off=0;                           
} 
void Video::write(char *cp)
{
     char *str = cp, *ch;
     for(ch = str;*ch;ch++)
     {
          put(*ch);
     }
}
void Video::put(char c)
{
     if(pos>=80)
     {
          pos = 0;
          off += 80;
     }
     if(off>=(80*25))
     {
          clear();                
     }            
     videomem[off + pos] = (unsigned char)c|0x0700;
     pos++;    
}
and at last when i make the linker and launch ld -T Link.ld -o Kernel.bin Loader.o Kernel.o Video.o
he says: ld:loader.o: file not recognized

thanks for help gyus... :)

Re: bootloader, kernel with C++

Posted: Mon Jan 24, 2011 3:27 pm
by PNoob
Hello

use the elf Format. "nasm -f elf loader.asm -o loader.o"

I hope i can hel you.

PNoob

PS: My Englisch ist not god. I'm from Germany

Re: bootloader, kernel with C++

Posted: Mon Jan 24, 2011 3:42 pm
by Cchedy
thinks for help.. 8)
but :( he still tell me that there is a problem :
cannot do operation PE on file type T1/2
pls help me

Re: bootloader, kernel with C++

Posted: Mon Jan 24, 2011 4:03 pm
by Combuster
Straight from the FAQ: GCC Cross-Compiler

Re: bootloader, kernel with C++

Posted: Mon Jan 24, 2011 4:17 pm
by Cchedy
hi,
finally i get it :idea:
i remove the linker and compile the three files .o to get the bin and i get the .bin... thanks for all of you.
last question pls: the file which i get has 64.kb, is that normal? :?: because i heared that he mustr have 512octes.
do you have any ideas where can i test it? :?:

Re: bootloader, kernel with C++

Posted: Mon Jan 24, 2011 6:33 pm
by Brynet-Inc
EDIT: Removed 2015: Imageshack replaced all links with spam.

Re: bootloader, kernel with C++

Posted: Mon Jan 24, 2011 6:50 pm
by Cchedy
??

Re: bootloader, kernel with C++

Posted: Mon Jan 24, 2011 9:53 pm
by linuxfood
Roughly translated from the above picture: "Oh what the -?"

More seriously,
Please ensure that you have the Required Knowledge.