Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!execu!sequoia!texbell!merch!cpe!hal6000!trsvax!don From: don@trsvax.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: Calling C functions from assembly Message-ID: <216100115@trsvax> Date: 2 Aug 89 13:41:00 GMT References: <12324@s.ms.uky.edu> Lines: 25 Nf-ID: #R:s.ms.uky.edu:12324:trsvax:216100115:000:1150 Nf-From: trsvax.UUCP!don Aug 2 08:41:00 1989 >>I'm trying to call some C functions from assembly, using MSC 5.0 and either >>MASM or TASM. I could write a dummy _main() in C, if this makes things >>easier, but I'm still not sure what needs to be setup to call a C subroutine. >> >>Can anyone clue me in on how to do this? >[...] >Note that the parameters are pushed onto the stack in reverse order. As >for how to retrieve the functions return value, you'l have to concult >you compilers documentation. There is no set convention, however most ^^^^^^^^^^^^^^^^^^^^^^^^^^ >use one of the CPU registers. If the routine doesn't return a value, >then all you have to worry about is pushing the parameters onto the >stack in reverse order, and restoring the stack when the routine is done. Is this correct? I thought it was a well-established convention to place the return value in the AX register. Are there some commercial compilers which return it somewhere else? --------------------------------------------------------------------- Don Subt The opinions expressed above are Tandy Corp. strictly mine, not my employer's. 817-390-3068 ...!texbell!letni!rwsys!trsvax!don