From: Ermin R. A. <e.a...@st...> - 2009-05-07 23:10:19
|
If I recall correctly, whenever I tried to use Win32 in my asm code I had to: a) use extern _MessageBoxA@16 (or whatever function I used) b) add User32.lib (or appropriate import library) to the linker Check up on stdcall name decorating if you're wondering why MessageBoxA is like that. Hope that helps, Robert -----Original Message----- From: <oh...@co...> To: Frank Kotler <fbk...@zy...> Date: Thu, 7 May 2009 5:52:23 -0400 Subject: Re: [Nasm-users] How to call MessageBoxA from Nasm program? Hi, To answer your question: I'm using the MS linker from Visual Studio 2008. So, are you saying that I can eliminate both the "extern" and the "import"? Thanks, Jim ---- Frank Kotler <fbk...@zy...> wrote: > oh...@co... wrote: > > Hi, > > > > I'm trying to add a call to MessageBoxA in a Nasm app. I know how to setup the parameters for the call, but I can't get Nasm to assemble successfully. > > > > I have added an "extern MessageBoxA" and "import MessageBoxA user32.dll" (this is on Windows), but when I do that, I get an error from parser saying that an instruction is expected. > > > > If I comment out the "import" line, I get a linker error. > > > > Am I not suppose to use both the "extern" and "import" lines, before the .Code line? > > Mmmm, yes, but only in "-f obj" output format (which defaults to 16-bit > and requires some "cruft" to tell Nasm we want 32-bit). Supposedly, in > "-f win32" format, we "don't need" it. I think the reason we "don't > need" it is that we are expected to link with an "import library" on the > linker command line. I am told that we can create our own import library > by assembling "extern MessageBoxA" and "import MessageBoxA user32.dll" > (with other extern/imports we need, presumably) as "-f obj" and linking > the produced .obj with the .obj containing your code (assembled as "-f > win32") - despite the different linkable object formats, this is > supposed to work. I was told this after I'd quit running Windows, so > never had a chance to try it. I think the more "usual" way would be to > link against an import library supplied with your linker(?). This raises > the obvious question: which linker are you using? And what, if anything, > came with it? I don't know much about Windows linkers - I used Alink, > mostly, for the few Windows programs I tried. I think Golink and Polink > are more common these days. > > You might want to download the "nasmx" package: > > http://www.asmcommunity.net/projects/nasmx/ > > Recent versions have been in .exe format, so I can't even look at it to > see what's there. Uses Golink, it says that on the web page... If it > doesn't include a "win32.lib" or such, the examples may give you an idea > how to function without it. > > If all else fails... > > http://home.comcast.net/~fbkotler/win32nasmbase.zip > > ...as I recall, that includes a library that worked with "-f win32", > although it is extremely old and obsolete... > > This question about "import" comes up fairly often, and I don't really > have a "good" answer to it, besides "it's for -f obj only" and we "don't > need" it for -f win32... Anyone got a clearer idea on this? > > Best, > Frank > > ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ Nasm-users mailing list Nas...@li... https://lists.sourceforge.net/lists/listinfo/nasm-users -------------------------------------------- Robert Alegrid #3164658 BP-079 Bachelor of Science (Physics) BP-083 Bachelor of Applied Science (Mathematics) |