Article View: alt.msdos.programmer
Article #190Re: Calling C functions from assembly
From: David Weigant
Date: Thu, 03 Aug 1989 18:25
Date: Thu, 03 Aug 1989 18:25
20 lines
1500 bytes
1500 bytes
In article <663@megatek.UUCP> hollen@zeta.megatek.uucp (Dion Hollenbeck) writes:
>From article <12324@s.ms.uky.edu>, by simon@ms.uky.edu (G. Simon Gales):
>> I'm trying to call some C functions from assembly, using MSC 5.0 and either
>
>Results are returned in registers. A char in AL, a
>short int in AX, a long int or float in AX/BX (low order in BX),
^
I believe you ment AX/DX for a long int or float. (High order or
segment in DX, low order or offset in AX).
Other things you might watch out for include C prefixing all variables
and function names with an underscore. To get them to link properly
you will have to use an underscore in your assembly code. Also,
you need to remember that in C, the calling routine needs to clear
the stack of any parameters passed into the function. For instance, if
you push an integer onto the stack and call a C function, you need to
pop the stack upon return from the function to remove the integer.
Hope this helps
David Weigant
Technical Details
Message-ID:
<7227@microsoft.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!microsoft!t-davidwReferences:
<12324@s.ms.uky.edu> <663@megatek.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!microsoft!t-davidw From: t-davidw@microsoft.UUCP (David Weigant) Newsgroups: alt.msdos.programmer,comp.sys.ibm.pc Subject: Re: Calling C functions from assembly Message-ID: <7227@microsoft.UUCP> Date: 3 Aug 89 18:25:27 GMT References: <12324@s.ms.uky.edu> <663@megatek.UUCP> Reply-To: t-davidw@microsoft.UUCP (David Weigant) Organization: Microsoft Corp., Redmond WA Lines: 20