Hello,
The document "Mixing Assembly and C" at this web site explain how mix assembly and C using DJGPP/NASM using 32 bits code. But, is posible mix these two programming lenguages using 16 bits code (to build a real mode OS)?
Thank you
Mixing Assembly and C (for 16 bits code)
RE:Mixing Assembly and C (for 16 bits code)
The languages yes, the tools no.
I don't think DJGPP/GCC can create real mode C code but NASM can do 16 bit assembly just fine. You'd just need to look at the docs for your 16 bit C compiler to make sure it does the same things as DJGPP like precede names with underscores, expect the same registers to be saved, etc. Be aware the C compilers can use different size variables especially when you're dealing with 16 bit vs 32 bit.
-Chase
I don't think DJGPP/GCC can create real mode C code but NASM can do 16 bit assembly just fine. You'd just need to look at the docs for your 16 bit C compiler to make sure it does the same things as DJGPP like precede names with underscores, expect the same registers to be saved, etc. Be aware the C compilers can use different size variables especially when you're dealing with 16 bit vs 32 bit.
-Chase
RE:Mixing Assembly and C (for 16 bits code)
Chase:
Thank you very mucho your soon response!
I will try with Turbo C v2.01 and the TASM...
Thank you very mucho your soon response!
I will try with Turbo C v2.01 and the TASM...
RE:Mixing Assembly and C (for 16 bits code)
Yes It is.
A (convoluted) example of that would be the GRUB bootloader. It mixes GNU AS-produced code with GCC-produced code that actually works in real mode. Now thats a hack... (Go look at the source for it )
Another (saner) way would be to wipe the dust off as86, ld86 and bcc (not borland compiler, but this http://www.linux.org/docs/ldp/howto/@$$ ... /as86.html)
A (convoluted) example of that would be the GRUB bootloader. It mixes GNU AS-produced code with GCC-produced code that actually works in real mode. Now thats a hack... (Go look at the source for it )
Another (saner) way would be to wipe the dust off as86, ld86 and bcc (not borland compiler, but this http://www.linux.org/docs/ldp/howto/@$$ ... /as86.html)