Asm in VC++
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
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.
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
#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
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
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
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......
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?
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?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement