• Advertisement

Archived

This topic is now archived and is closed to further replies.

Asm in VC++

This topic is 6443 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, im using visual studio 6.0(vc++ 6) and im a fan of assembley inside my programs(i hate inline asm) im trying to get MASM 6.15 to work with vc++ to no avail, and regardless of what option or setting i set i get unresolved externals everywhere. anyone ever done this? Microsofts site had some instructions on their site(none of which worked) and im out of ideas. its not name mangiling, as i define everything extern "C" as instructed. maybe im linking wrong or something. thanks. ~ Chris

Share this post


Link to post
Share on other sites
Advertisement
I think your problem has to do with your *.lib files I had the same happen to me. You said you went to microsofts website. Look around more I think that they have extra library files for MASM 6.12. I''m sorry I wish I could help more.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
heres an example of how to run a simple assembly program under c++. Remember, when using assembly and c++ like this you need to know how the variables are pushed on the stack by the compiler you are using in order to pop them off in the correct order. be sure to include the add.asm file!


#include
#include
extern "C" near ADD(int p1, int p2, int p3);
int a,b,c,total;
void main()
{ a = 5;
b = 10;
c = 15;
ADDEM(a,b,c);
cout<<"Total = "<}

title addem subroutine in a file called (add.asm)
public _ADD
dosseg
.model small
.code
_ADD proc near
push bp
mov bp,sp
mov ax,[bp +8]
add ax,[bp +6]
add ax,[bp +4]
pop bp
ret
_ADD endp
end


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
what happened?? those two includes were iostream.h and conio.h
and the cout should also cout the var total, not just the text!! i dont know what happened, maybe next time i''ll double check things. but remember to include the .asm file in your project

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The reason that it took out the include is that you put them between the angled brackets... they dont like people putting their own html into these forums so they automatically take it out......

Share this post


Link to post
Share on other sites
Hey im in the same boat.

I just need to know what you do with the assembly files. Do you leave them as text and just change the ending to .asm? Thats kinda like C source files I guess. Or do you do the partial compile thing where linking and stuff is left undone?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi all.

Redknite, I understand what you are going thru, it is a pain in the neck to integrate assembler into your project without the proper documentation.

First, make sure you are exporting all functions

externdef FunctionName :near

Make sure you include something like this at the top of each source file, before anything else:

.386
.model flat,stdcall

If you do not specify the stdcall keyword, then you need to include it in the export declaretion:

externdef stdcall FunctionName :near

If you do not include the stdcall keyword in any of those places, the linker won''t find the file because the assembler is exporting, say, function "FOO", and the C compiler is asking for a function called "_FOO". the stcall keyword causes the assembler to export "_FOO" rather than "FOO".

These are the only things that come to my mind other than basic stuff like adding the files to the proyect, etc.

If you still need help, and if you wanted, make a small test project, send it to me and I will check it out and tell you wnat you are missing.

Topgoro
Topgoro@yahoo.com

Share this post


Link to post
Share on other sites

  • Advertisement