Mixing Assembly and C  (for 16 bits code)

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
Pepito

Mixing Assembly and C  (for 16 bits code)

Post by Pepito »

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
Chase

RE:Mixing Assembly and C  (for 16 bits code)

Post by Chase »

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
Pepito

RE:Mixing Assembly and C  (for 16 bits code)

Post by Pepito »

Chase:

Thank you very mucho your soon response!

I will try with Turbo C v2.01 and the TASM...
Reply

RE:Mixing Assembly and C  (for 16 bits code)

Post by Reply »

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 :-D)

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)
Post Reply