OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 2:35 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Printing text with C is showing weird screen.
PostPosted: Fri Aug 25, 2017 2:44 pm 
Offline
User avatar

Joined: Wed Aug 23, 2017 1:09 pm
Posts: 20
I'm trying to print text to the screen in C and whenever I run my OS with Qemu I get this image. I'm following this Github user and this PDF file for a tutorial. When I downloaded his files from github and ran his OS in Qemu I get the same result. The clear_screen() function works, I commented out the print functions and the screen is cleared. These are my files if you'll please check them out for me.
Image

EDIT: I've been messing with the code and I think it has something to do with getting and setting the offset.

_________________
Gigaboy


Top
 Profile  
 
 Post subject: Re: Printing text with C is showing weird screen.
PostPosted: Fri Aug 25, 2017 5:31 pm 
Offline
Member
Member

Joined: Fri Aug 19, 2016 10:28 pm
Posts: 360
If you are using 64 bit host to build, you need to pass -m32 to compiler, -m elf_i386 to the linker, -f elf32 to the assembler. After those fixes it works on my end.


Top
 Profile  
 
 Post subject: Re: Printing text with C is showing weird screen.
PostPosted: Fri Aug 25, 2017 5:42 pm 
Offline
User avatar

Joined: Wed Aug 23, 2017 1:09 pm
Posts: 20
simeonz wrote:
If you are using 64 bit host to build, you need to pass -m32 to compiler, -m elf_i386 to the linker, -f elf32 to the assembler. After those fixes it works on my end.

Thanks that worked for me too.

_________________
Gigaboy


Top
 Profile  
 
 Post subject: Re: Printing text with C is showing weird screen.
PostPosted: Fri Aug 25, 2017 7:06 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
simeonz wrote:
If you are using 64 bit host to build, you need to pass -m32 to compiler, -m elf_i386 to the linker, -f elf32 to the assembler. After those fixes it works on my end.

Actually, you (and the OP) should use a cross-compiler.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: Printing text with C is showing weird screen.
PostPosted: Fri Aug 25, 2017 8:13 pm 
Offline
Member
Member

Joined: Fri Aug 19, 2016 10:28 pm
Posts: 360
omarrx024 wrote:
simeonz wrote:
If you are using 64 bit host to build, you need to pass -m32 to compiler, -m elf_i386 to the linker, -f elf32 to the assembler. After those fixes it works on my end.

Actually, you (and the OP) should use a cross-compiler.
You mean in order to get proper libgcc, or there are differences in the code generator? The object files that provide arithmetic functions in libgcc do not call into the platform. And the code generator I imagine should be agnostic. Or you mean as a principle, because any other use is unsupported officially?

Also, if a person decides to use C++ in the kernel, there is little chance to get correct platform agnostic i386 support for exceptions, because they need thread local storage to operate (i.e. to track the current exception during unwinding.) Which means you will have to get dirty with rewriting at least a small amount of internal functions.

P.S. I have a cross-compiler lying around. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], WinExperements and 112 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group