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.
EDIT: I've been messing with the code and I think it has something to do with getting and setting the offset.
Printing text with C is showing weird screen.
Re: Printing text with C is showing weird screen.
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.
Re: Printing text with C is showing weird screen.
Thanks that worked for me too.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.
Gigaboy
- BrightLight
- Member
- Posts: 901
- Joined: Sat Dec 27, 2014 9:11 am
- Location: Maadi, Cairo, Egypt
- Contact:
Re: Printing text with C is showing weird screen.
Actually, you (and the OP) should use a cross-compiler.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.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Re: Printing text with C is showing weird screen.
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?omarrx024 wrote:Actually, you (and the OP) should use a cross-compiler.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.
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.