Dll MASM32中的crt_printf和ExitProcess与lib crt\U printf、crt\U scanf、ExitProcess 环境路径为masm32v11r的Windows 7
在.asm文件中,我想调用crt_printf来打印(或者调用ExitProcess来结束主过程)。但是,我的代码是:Dll MASM32中的crt_printf和ExitProcess与lib crt\U printf、crt\U scanf、ExitProcess 环境路径为masm32v11r的Windows 7,dll,printf,masm32,Dll,Printf,Masm32,在.asm文件中,我想调用crt_printf来打印(或者调用ExitProcess来结束主过程)。但是,我的代码是: .386 .model flat,stdcall option casemap:none includelib D:\masm32\lib\msvcrt.lib printf proto C:dword,:vararg scanf proto C:dword,:vararg .DATA print_int DB "%d",0 print_char
.386
.model flat,stdcall
option casemap:none
includelib D:\masm32\lib\msvcrt.lib
printf proto C:dword,:vararg
scanf proto C:dword,:vararg
.DATA
print_int DB "%d",0
print_char DB "%c",0
PUSH offset __temp13@_cal@main
PUSH offset print_string
CALL crt_printf
ADD ESP, 8
PUSH _realCock@main
PUSH offset print_int
CALL crt_printf
ADD ESP, 8
PUSH offset __temp14@_cal@main
我的通话程序如下:
.386
.model flat,stdcall
option casemap:none
includelib D:\masm32\lib\msvcrt.lib
printf proto C:dword,:vararg
scanf proto C:dword,:vararg
.DATA
print_int DB "%d",0
print_char DB "%c",0
PUSH offset __temp13@_cal@main
PUSH offset print_string
CALL crt_printf
ADD ESP, 8
PUSH _realCock@main
PUSH offset print_int
CALL crt_printf
ADD ESP, 8
PUSH offset __temp14@_cal@main
当我单击“全部构建”按钮时,会出现以下消息:
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: D:\masm32\bin\object_code.asm
D:\masm32\bin\object_code.asm(105) : error A2006: undefined symbol : crt_printf
D:\masm32\bin\object_code.asm(109) : error A2006: undefined symbol : crt_printf
D:\masm32\bin\object_code.asm(179) : error A2006: undefined symbol : crt_scanf
D:\masm32\bin\object_code.asm(249) : error A2006: undefined symbol : ExitProcess
Assembly Error
我已经和这样的错误斗争了24小时,谢谢
crt\u printf
是MASM32开发人员的一种特殊构造,用于将其与他们的宏printf
区分开来。如果不包括\masm32\macros\macros.asm
,则不需要此特殊功能:
.386
.model flat,stdcall
includelib \masm32\lib\msvcrt.lib
includelib \masm32\lib\kernel32.lib
printf proto C :dword, :vararg ; msvcrt
ExitProcess proto STDCALL :DWORD ; kernel32
.DATA
fmt db "%s",10,0
hello db "Hello world!",0
.CODE
main PROC
push OFFSET hello
push OFFSET fmt
call printf
add esp, (2 * 4)
push 0
call ExitProcess
main ENDP
END main
crt.
别名在msvcrt.inc
中声明:
.386
.model flat,stdcall
include \masm32\include\msvcrt.inc
includelib \masm32\lib\msvcrt.lib
includelib \masm32\lib\kernel32.lib
printf proto C :dword, :vararg ; msvcrt
ExitProcess proto STDCALL :DWORD ; kernel32
.DATA
fmt db "%s",10,0
hello db "Hello world!",0
.CODE
main PROC
push OFFSET hello
push OFFSET fmt
call crt_printf
add esp, (2 * 4)
push 0
call ExitProcess
main ENDP
END main
include \masm32\include\masm32rt.inc
.DATA
fmt db "%s",10,0
hello db "Hello world!",0
.CODE
main PROC
push OFFSET hello
push OFFSET fmt
call crt_printf
add esp, (2 * 4)
printf ("Hello again: %s\n",OFFSET hello);
push 0
call ExitProcess
main ENDP
END main
如果您想要全部声明和宏,那么就包括masm32rt.inc
:
.386
.model flat,stdcall
include \masm32\include\msvcrt.inc
includelib \masm32\lib\msvcrt.lib
includelib \masm32\lib\kernel32.lib
printf proto C :dword, :vararg ; msvcrt
ExitProcess proto STDCALL :DWORD ; kernel32
.DATA
fmt db "%s",10,0
hello db "Hello world!",0
.CODE
main PROC
push OFFSET hello
push OFFSET fmt
call crt_printf
add esp, (2 * 4)
push 0
call ExitProcess
main ENDP
END main
include \masm32\include\masm32rt.inc
.DATA
fmt db "%s",10,0
hello db "Hello world!",0
.CODE
main PROC
push OFFSET hello
push OFFSET fmt
call crt_printf
add esp, (2 * 4)
printf ("Hello again: %s\n",OFFSET hello);
push 0
call ExitProcess
main ENDP
END main