I am writing windows functions in assembly language for use in c++ programs, but I can't figure out how to pass parameters from the c++ code to the assembly code. The assembly when assembled and linked runs fine, but when I tried to use the function in c++ it said missing storage-class or type specifiers. The value I'm trying to pass is a string and in the assembly code I have it as a dword, but there has to be a remedy to this...
First,
Most of these generic questions could best be answered by doing a search of this board...
Second,
If it isn't generic it would help facilitate the answering of your question by giving the source (or part of it) so we can debug it...
Since i have not much to work with -- I just did a search for you and found another generic post where "how do i call assembly procedures in c++" was answered
click here for that thread
Most of these generic questions could best be answered by doing a search of this board...
Second,
If it isn't generic it would help facilitate the answering of your question by giving the source (or part of it) so we can debug it...
Since i have not much to work with -- I just did a search for you and found another generic post where "how do i call assembly procedures in c++" was answered
click here for that thread
Since this is a guessing game, can we assume that you are correctly passing a pointer to the string, or using the '&' operator to pass its address?
First I told you exactly what I am doing, and told you the debugger error. Yes I'm using the & operator. Okay you want to see the code? Here it is:
MakeWin((unsigned int)&string);
in assembly:
MakeWin PROTO string:DWORD
MakeWin((unsigned int)&string);
in assembly:
MakeWin PROTO string:DWORD
When you declared MakeWin prototype did you make this:
The _stdcall is the important part here. Because otherwise the calling conversion will default to _cdecl.
then when you do something like:
You will be fine. Note that I use strTest and not &strTest this is because what you want is a pointer to a string and not a pointer to a pointer to a string.
BTW:
I would advice not to use string as a variable name, since there is a template called string in the C++ STL. This could cause confution on the long run.
void _stdcall MakeWin(char * str);
The _stdcall is the important part here. Because otherwise the calling conversion will default to _cdecl.
then when you do something like:
char * strTest = "This is a Test";
....
MakeWin(strTest);
You will be fine. Note that I use strTest and not &strTest this is because what you want is a pointer to a string and not a pointer to a pointer to a string.
BTW:
I would advice not to use string as a variable name, since there is a template called string in the C++ STL. This could cause confution on the long run.