From: Frank K. <fbk...@zy...> - 2009-05-08 02:33:29
|
oh...@co... wrote: > Hi, > > To answer your question: I'm using the MS linker from Visual Studio 2008. Googling "nasm visual studio" comes up with a few links... The gist of it seems to be: --------------------------- Integration within Microsoft Visual Studio 6 Since 0.95.36, NASM is fully officially compatible with Microsoft Visual Studio 6 / .NET - In Tools/Options/Directories, Select 'Show directories for:' into 'Executable files'. Add a new path "C:\Program Files\NASM" (or where you have installed Nasm) - In your project workspace, create a new folder 'Assembler Files'. - On this folder, right click and select 'Settings.' - In General, enable 'Always use custom build step'. - In Custom Build, change the following settings : Integration within Microsoft Visual .NET 2003 - In Tools/Options/Projects, Select 'VC++ Directories ' and 'Show directories for:' 'Executable files' - Should be the default. Press Ctrl-Insert or press the 'New Line' icon. Select the path "C:\Program Files\NASM" (or where you have installed Nasm) - In your project workspace, create a new folder 'Assembler Files'. - On this folder, right click and select 'Settings.' - In General, enable 'Always use custom build step'. - In Custom Build, change the following settings : Commands nasmw.exe -f win32 -Xvc -o "$(IntDir)\$(InputName).obj" $(InputDir)\$(InputName).asm Outputs "$(IntDir)\$(InputName).obj" --------------------------- The reference to "fully compatible" only means the "-Xvc" option, which switches error messages to a format MS tools like - a case of parentheses around the line number, IIRC. Will make a difference within the IDE, otherwise not, I think. > So, are you saying that I can eliminate both the "extern" and the "import"? No, just the "import". Pretty sure you'll still need the "extern"... although it is sometimes hidden in the macros in an .inc file. The above instructions don't mention anything about the linker. I found this "raw" example from Matt Taylor... (I don't think we need the "bits 32" - won't hurt) ------------ bits 32 extern __imp__ExitProcess@4 section .text _start: push 0 call [__imp__ExitProcess@4] I assemble and link like this: nasm -f win32 win32test.asm -o win32test.obj link /ENTRY:start /SUBSYSTEM:console win32test.obj kernel32.lib /OUT:win32test.exe ------------------------- This assumes you've got "kernel32.lib"... part of VS?... in a lib/ directory, most likely... Note that the names are "decorated" (mutilated) even more than what Robert shows. I *think* we can either "call _FooApi@?" or "call [__IMP__FooApi@?]" - the number is the number of bytes of parameters expected (removed, unseen by us, in the called function... except for variadic functions like printf, and *maybe* all C functions - as opposed to Windows APIs... in "msvc32.dll"???) Again, I think it is "usual" to have some of the "renaming" hidden away in a macro in an .inc file. I'd try it "raw" first - might take some experimentation - so you understand what's "really" happening. Good Luck! Best, Frank |