well, the question is simple, I want to write a simple operating system
just for learning purposes, I already have some intresting ideas on how
to start coding it but I have a backgroung problem: once my system has booted
and is stable in Protected Mode I would need a C/C++ compiler implemented
in order not to code everything in assembly (It would be nice an assemply
cmopler too...) or working on another machine and copy/rebooting/testing
all the time. Is there any simple way in which i can port an existing C/C++
compiler in my newly created OS which lacks any advanced functionality?(for
example it only has a basic shell or few video-keyboard input output support).
I hope I was clear enough, thanks in advance
porting C/C++ compilers
RE:porting C/C++ compilers
I would investigate using LCC (in particular, the older version 3.6, which has a lot of documenation based on it, and a book written about it).
You can work in phazes, as well. I've adapted LCC to use Nasm as a backend, and to use the rdoff object format for output. Therefore, for the time being, I can compile my applications in Linux, copy them to my native file system, and then execute them.
Also, I can now use this altered LCC to develop my libc implementation. When finished, I should then be able to recompile LCC itself, withen my altered LCC, therefore creating a native version of the LCC compiler, for my operating system.
At this point, I can then develop programs withen my OS (well... after having ported NASM to my OS as well, of course).
Cheers,
Jeff
PS: As an alternative, you can write a C compiler from scratch It's an excellent learning experience! I'm currently writting a compiler for my own language... altering it for C wouldn't be _overly_ difficult
You can work in phazes, as well. I've adapted LCC to use Nasm as a backend, and to use the rdoff object format for output. Therefore, for the time being, I can compile my applications in Linux, copy them to my native file system, and then execute them.
Also, I can now use this altered LCC to develop my libc implementation. When finished, I should then be able to recompile LCC itself, withen my altered LCC, therefore creating a native version of the LCC compiler, for my operating system.
At this point, I can then develop programs withen my OS (well... after having ported NASM to my OS as well, of course).
Cheers,
Jeff
PS: As an alternative, you can write a C compiler from scratch It's an excellent learning experience! I'm currently writting a compiler for my own language... altering it for C wouldn't be _overly_ difficult
RE:porting C/C++ compilers
let me see, you say your technique is that of compiling in Linux(in an appropriate format)/copying to your OS filesystem/testing. So first I would have to build the right "environment" (inside my OS) in order to satisfy the compiler's code needings (what about dynamic libraries eventually required?), compile in Linux and than run the executable in my OS. Is analyzing all the compiler's code such a big effort as it seems to me ? What kind of problems did you encounter ?