Hi Everyone

Yesterday I tried out the post that Sluggy posted on using
Visual C++ as a debugger, Well it worked Great for making pure assembly programs, But I'd like to be able use Masm functions like
invoke StdOut, ADDR variable
in ASM procedures for Visual C++ programs, at the moment I only know how to use
C functions like call printf , etc in my external asm procedures

I think I'm getting closer to this goal with the info Sluggy posted
because it showed how to add Masm32 to my directory paths


Is there another command like this but different
ml /c /Cx /coff /Cp /Zi /Zd $(InputPath)

that will enable certain asm files to access the Masm32 directories
and let the C++ files access the directories they need

instead of this
error
unresolved external symbol _qsortnumsD

Thanks Andy



Here is what Sluggy posted

Here you go... i have cut and pasted this from a newsgroup posting, and it works great. Once you have the project set up, you can do all the usual dragging & dropping of files between the folders in the file explorer pane, add new files to it, etc.



quote:
--------------------------------------------------------------------------------

Procedure for creating a new MASM project in Visual Studio 6.0:

1. Put your MASM files (e.g., ml.exe) in any directory
you want. In Visual Studio, include that directory in Tools ? Options ?
Directories. When you assemble, Visual Studio will search for the MASM
files there. Also include the directories where you have your include
files. This process only needs to be done once; it remains a ?global?
setting for all MASM projects you subsequently create.

2. Create a new project (as a Win32 application) with
the same name as your ASM file. It should create a blank Win32 workspace by
the same name.

3. Copy your ASM and resource file(s) into the project
directory. Then Click ?Project? at the top of the window, then choose ?Add
to Project? and choose ?Files.? Add in your ASM file and your resource file
(.RC file). The RC file must also have the same name as the ASM file.

4. Select (click on) the name of your ASM file or files,
then either right click or click ?Project? at the top of the window, and
choose ?Settings.? Under the ?Custom Build? tab, insert the following in
the box headed ?Commands.?

ml /c /Cx /coff /Cp /Zi /Zd $(InputPath)

Put in the $(InputPath) by clicking on the ?Files?
button at the bottom and choosing Input Path. Do not put in the name of
your ASM file; Visual Studio will do it for you.

Then insert the following in the box headed
?Outputs.?

$(InputName).obj

Again, put in the $(InputName) by clicking on the
?Files? button at the bottom and choosing Input Name, and append .obj to the
end. Do not put in the name or your OBJ file; Visual Studio will do it for
you. The ASM, RC and OBJ files all have the same name by default.

DO NOT REPEAT THIS FOR THE GLOBAL PROJECT SETTINGS.
DO IT ONLY FOR THE ASM FILE OR FILES, BY RIGHT-CLICKING ON THE FILE NAME(S).

It should not be necessary to put in include library
paths in the Link tab as they have been globally set in the
tools/options/directories/executables path.

Procedure to set up new installation of Visual Studio for MASM

1. Close all open workspaces in Visual Studio.

2. Click Tools . . . Options, on the top toolbar.

3. On the Directories tab, use the drop-down window
labelled ?show directories for.?

4. Select ?Executables? and add c:\MASM32\BIN.

5. Select ?Include files? and add c:\MASM32\INCLUDE.

6. Select ?Library files? and add:

c:\MASM32\LIB

c:\MASM32\M32LIB

7. For each project, if it was copied in from another
PC, the Custom Build settings should already be set. If not, use the
instructions above to set the custom build settings for each ASM file.
Posted on 2002-01-11 10:17:34 by andy981
There seem to be very little info on the net about mixing masm with Visual C++, has anyone out there sucessfully added an ASM procedure that had Masm32 functions in it
like
invoke StdOut,Addr variable

to
a visual C++ program

Andy

:stupid:
Posted on 2002-01-11 22:08:57 by andy981
In a C or C++ program ? In a C program, declare your function with the __stdcall keyword. In a C++, use extern "C". For example if you have a function Init in an asm file :

Init PROTO

Init PROC
Init ENDP

In a .c, use :

void __stdcall Init();

In a C++ file use :

extern "C"
{
void __stdcall Init();
}
Posted on 2002-01-12 09:30:43 by Dr. Manhattan
Thanks Dr. Manhattan
For showing me how use Masm32 functions with C and C++

And to show others here is the info

Use the info in my first post from Sluggy
Tose up everything
Procedure for creating a new MASM project in Visual Studio 6.0:



In a .c, use :

void __stdcall qsortnumsD(int, int);



for C++ file

extern "C"
{
void __stdcall qsortnumsD(int, int);
}

ASM file

#########################################################################
; 32 bit memory model

.386



.MODEL flat, stdcall

option casemap :none ; case sensitive

include \masm32\include\oleaut32.inc
.data
.code

; #########################################################################

qsortnumsD proc Arr:DWORD,count:DWORD

rest of code

ret

qsortnumsD endp

; #########################################################################

end
Posted on 2002-01-12 12:17:30 by andy981
For making something that works both on C and C++



#ifdef _cplusplus
extern "C" {
#endif

void __stdcall qsortnumsD(int, int);

#ifdef _cplusplus
}
#endif


That way it will have the extern "C" only on C++

even better you can do:



;/* Assembler

qsortnumsD proto :dword, :dword

comment `
*/

// C/C++

#ifdef _cplusplus
extern "C" {
#endif

void __stdcall qsortnumsD(int, int);

#ifdef _cplusplus
}
#endif

//`


and have a header that will work on asm, C and C++, notice the Grave accent (`) after the keyword comment. This will make the assembler ignore everything until it finds the (`) again.
Posted on 2002-01-12 17:42:08 by dxantos
comment `
*/

Thanks for tip about

#ifdef __cplusplus
extern "C" {
#endif
void __stdcall qsortnumsD(int, int); //<- prototype
#ifdef __cplusplus
}
#endif

Also I was'nt aware of the required word comment`
to comment stuff out so you've saved me millions of semi colons in the future.

Yes I'm sure glad I found how to use masm functions with C
I've been wanting to know how to do that for a while.
I need to do a tutorial on this. Because it's not readily found on the web





*\
`
Posted on 2002-01-12 22:06:13 by andy981