Re: HELP! >MASM CALLING C FUNCTIONS.. FROM ASM :)
From: hutch-- (hutch_at_movsd.com)
Date: 11/23/03
- Next message: Child of God: "Re: A Parable of Two Carpenters"
- Previous message: Randall Hyde: "Re: A Parable of Two Carpenters"
- In reply to: Randall Hyde: "Re: HELP! >MASM CALLING C FUNCTIONS.. FROM ASM :)"
- Next in thread: T.M. Sommers: "Re: HELP! >MASM CALLING C FUNCTIONS.. FROM ASM :)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 22 Nov 2003 21:25:55 -0800
steve),
> > .386
> > .387
> > .model FLAT,STDCALL
> > .code
> > org 100
> >
> > ;sections below commented out would not LINK!!!!!!!
> > _start_code:
> > ;extern func1:far
> > mov eax,00abcdefh
> > ;call func1
> >
> > end _start_code
There are a number of things you must get right first, to use a C
library you need to use the "includelib" syntax so the assembler knows
where to find the library.
includelib My_C_Library.lib
To call a function in the C library you must write a prototype for it
and specify the calling convention. It will usually be C but it can
also be STDCALL.
MyCfunc PROTO C :DWORD,:DWORD
Then you can call it using the INVOKE syntax.
invoke MyCfunc,arg1,arg2
To terminate the program, you need to use the API call ExitProcess.
invoke ExitProcess,0
If you don't have the MASM32 include files, you need a prototype and a
library for that API call.
include kernel32.lib
ExitProcess PROTO :DWORD
I would recommend you get the MASM32 project at www.masm32.com as it
has all of the include files and a lot of other toys that are useful
in writing assembler projects.
Regards,
hutch at movsd dot com
- Next message: Child of God: "Re: A Parable of Two Carpenters"
- Previous message: Randall Hyde: "Re: A Parable of Two Carpenters"
- In reply to: Randall Hyde: "Re: HELP! >MASM CALLING C FUNCTIONS.. FROM ASM :)"
- Next in thread: T.M. Sommers: "Re: HELP! >MASM CALLING C FUNCTIONS.. FROM ASM :)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|