bootloader, kernel with C++

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
Cchedy
Posts: 22
Joined: Mon Jan 24, 2011 2:49 pm

bootloader, kernel with C++

Post 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... :)
PNoob
Posts: 1
Joined: Mon Jan 24, 2011 3:23 pm

Re: bootloader, kernel with C++

Post 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
Cchedy
Posts: 22
Joined: Mon Jan 24, 2011 2:49 pm

Re: bootloader, kernel with C++

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: bootloader, kernel with C++

Post by Combuster »

Straight from the FAQ: GCC Cross-Compiler
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Cchedy
Posts: 22
Joined: Mon Jan 24, 2011 2:49 pm

Re: bootloader, kernel with C++

Post 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? :?:
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: bootloader, kernel with C++

Post by Brynet-Inc »

EDIT: Removed 2015: Imageshack replaced all links with spam.
Last edited by Brynet-Inc on Fri Aug 28, 2015 8:52 pm, edited 1 time in total.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Cchedy
Posts: 22
Joined: Mon Jan 24, 2011 2:49 pm

Re: bootloader, kernel with C++

Post by Cchedy »

??
User avatar
linuxfood
Member
Member
Posts: 38
Joined: Wed Dec 31, 2008 12:22 am

Re: bootloader, kernel with C++

Post by linuxfood »

Roughly translated from the above picture: "Oh what the -?"

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