Xref: utzoo alt.msdos.programmer:252 comp.sys.ibm.pc:32439 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!topgun.dspo.gov!lanl!opus!pgaughan From: pgaughan@dante.nmsu.EDU (Patrick Gaughan) Newsgroups: alt.msdos.programmer,comp.sys.ibm.pc Subject: Re: Calling C functions from assembly Message-ID: Date: 1 Aug 89 15:59:07 GMT References: <12324@s.ms.uky.edu> Sender: news@nmsu.edu Followup-To: alt.msdos.programmer Organization: New Mexico State University, Las Cruces, NM Lines: 43 In-reply-to: simon@ms.uky.edu's message of 1 Aug 89 14:21:07 GMT Well, I've done some stuff in this area... The easiest way I can think of is to use the LARGE option on your C compiler, declare the C functions as far labels and use far calls from the assembly language routine. Example: /* c program */ #include int cfnct(a,b) int a,b; { printf("a + b = %d\n",a+b); return (a+b); } ; asm program ( miscellaneous instructions ) EXTERN _cfcnt:FAR ; depending on linker, name may not be . ; case sensitive . . push b push a call cfcnt add sp,4 (function return value in ax, if the function was a long or ptr type, dx would return the upper half of the return value) I'm pretty sure this is correct, but you'll have to try it and prove it for yourself. Like most programmers, I don't memorize every rule, but given a machine and I few tries at it, I can usually remember how to do it. Disclaimer: You're getting desperate if you think I have all the right answers... Patrick Gaughan pgaughan@nmsu.edu