Hi, the following error occurs, when I wnat to compile my soucce:
ASM-File:
__________________________________________
.386
.MODEL FLAT, STDCALL
OPTION CASEMAP:NONE
INCLUDE Include\WINDOWS.INC
INCLUDE Include\KERNEL32.INC
INCLUDE Include\USER32.INC
INCLUDE Include\MASM32.INC
INCLUDELIB Library\KERNEL32.LIB
INCLUDELIB Library\USER32.LIB
INCLUDELIB Library\MASM32.LIB
.const
dateiname EQU + 8
string EQU + 6
.code
_SchreibeDaten PROC PUBLIC
PUSH EBP
MOV EBP, ESP
INVOKE MessageBox, NULL, ADDR dateiname, ADDR dateiname, NULL
RET 1
_SchreibeDaten ENDP
END
???????????????????????????????????????????????????
CPP-File:
_____________________________________________________
extern NEAR int SchreibeDaten(char c_dateiname, char c_string);
SchreibeDaten("Huhu", "huhuagain");
??????????????????????????????????????????????????????
In the option I add the obj-File fomr the asm-proc.
What could be wrong ?
:confused: :stupid:
Greets FF
ASM-File:
__________________________________________
.386
.MODEL FLAT, STDCALL
OPTION CASEMAP:NONE
INCLUDE Include\WINDOWS.INC
INCLUDE Include\KERNEL32.INC
INCLUDE Include\USER32.INC
INCLUDE Include\MASM32.INC
INCLUDELIB Library\KERNEL32.LIB
INCLUDELIB Library\USER32.LIB
INCLUDELIB Library\MASM32.LIB
.const
dateiname EQU + 8
string EQU + 6
.code
_SchreibeDaten PROC PUBLIC
PUSH EBP
MOV EBP, ESP
INVOKE MessageBox, NULL, ADDR dateiname, ADDR dateiname, NULL
RET 1
_SchreibeDaten ENDP
END
???????????????????????????????????????????????????
CPP-File:
_____________________________________________________
extern NEAR int SchreibeDaten(char c_dateiname, char c_string);
SchreibeDaten("Huhu", "huhuagain");
??????????????????????????????????????????????????????
In the option I add the obj-File fomr the asm-proc.
What could be wrong ?
:confused: :stupid:
Greets FF
Calling C functions from assembly and vice versa was discussed multiple times here:
http://www.asmcommunity.net/board/index.php?topic=11459
http://www.asmcommunity.net/board/index.php?topic=11266
http://www.asmcommunity.net/board/index.php?topic=9531
http://www.asmcommunity.net/board/index.php?topic=9510
http://www.asmcommunity.net/board/index.php?topic=9008
http://www.asmcommunity.net/board/index.php?topic=8377
Please search with the
button next time.
Thanks!
http://www.asmcommunity.net/board/index.php?topic=11459
http://www.asmcommunity.net/board/index.php?topic=11266
http://www.asmcommunity.net/board/index.php?topic=9531
http://www.asmcommunity.net/board/index.php?topic=9510
http://www.asmcommunity.net/board/index.php?topic=9008
http://www.asmcommunity.net/board/index.php?topic=8377
Please search with the

Thanks!
You need some serious help - and you need to read the FAQ section of this board.
linkage of asm+C/C++ - read the FAQ.
furthermore, you don't really seem to know wtf you're doing - "ret 1" ? having your proc after "start:", and "end start" in something that is presumably meant to be linked in as a utility function, not the program body? Using german names for procs and data?
I'd say you're not ready for assembly.
linkage of asm+C/C++ - read the FAQ.
furthermore, you don't really seem to know wtf you're doing - "ret 1" ? having your proc after "start:", and "end start" in something that is presumably meant to be linked in as a utility function, not the program body? Using german names for procs and data?
I'd say you're not ready for assembly.
Even though hutch probably thinks people are retards, by using hardcoded paths in masm32 and not allowing you to install to network drive (last time I used the installer anyway), he does have these wise words to say:
MASM32 assumes that the programmers who will use it already have experience in 32 bit Windows API programming using compilers and have done some work in assembler. It is not designed as a beginners package and it does not have the support for beginners to learn the basic concepts about assembler.
MASM32 assumes that the programmers who will use it already have experience in 32 bit Windows API programming using compilers and have done some work in assembler. It is not designed as a beginners package and it does not have the support for beginners to learn the basic concepts about assembler.
I don't really like cdecl , use stdcall
Hope it works.
.386
.model flat,stdcall
option casemap:none
include /masm32/include/user32.inc
includelib /masm32/lib/user32.lib
.code
start:
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
_SchreibeDaten proc
invoke MessageBox, 0, [esp+4],[esp+8],0
leave
retn 4*2
_SchreibeDaten endp
OPTION PROLOGUE:PROLOGUEDEF
OPTION EPILOGUE:EPILOGUEDEF
end start
Hope it works.
I don't really like cdecl , use stdcall
.386
.model flat,stdcall
option casemap:none
include /masm32/include/user32.inc
includelib /masm32/lib/user32.lib
.code
start:
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
_SchreibeDaten proc
invoke MessageBox, 0, [esp+4],[esp+8],0
leave
retn 4*2
_SchreibeDaten endp
OPTION PROLOGUE:PROLOGUEDEF
OPTION EPILOGUE:EPILOGUEDEF
end start
Hope it works.
Remember that function parameters are pushed on the stack so your esp offsets will need to be adjusted. Also, if you don't have a stackframe you don't want 'leave'.
Thomas
I just wunder wich library or dll I have to include.
I already seek aorung, but nothing found.
I did this for 4 years ago and everithing worked fine, but now I have some problems.
Thanks for helping !
I already seek aorung, but nothing found.
I did this for 4 years ago and everithing worked fine, but now I have some problems.
Thanks for helping !
Remember that function parameters are pushed on the stack so your esp offsets will need to be adjusted. Also, if you don't have a stackframe you don't want 'leave'.
Thanks for informing me. I forgot about the pushs changing the esp and did not know that you do not need leave if I did not have a stackframe.
One unresolved function, what can I do ? :confused:
extern "C"
Thomas
Thomas
btw this won't work either:
The chars should be char pointers (char*).
Thomas
extern NEAR int SchreibeDaten(char c_dateiname, char c_string);
The chars should be char pointers (char*).
Thomas
I think I have to include a specify library oder dll.
But wich ?
But wich ?
No you don't have to, just change it to extern "C" and add *'s to the chars.
Thomas
Thomas
Hi, I did.
Perhaps its wbecaue I use Visual C++ ?
Perhaps its wbecaue I use Visual C++ ?
.486
.model flat, stdcall
option casemap:none
include <windows.inc>
include <user32.inc>
includelib <user32.lib>
.code
public SchreibeDaten
SchreibeDaten proc pMsg:dword, pTitle:dword
invoke MessageBox, NULL, pMsg, pTitle, NULL
ret
SchreibeDaten endp
end
extern "C"
{
void __stdcall SchreibeDaten(const char *pMessage, const char *pTitle);
}
Thomas
Hey ultra-thanks ! - Now It works !:grin: :stupid: :stupid: :stupid: :stupid: :stupid:
Thanks a lot !
Thanks a lot !