Assembly 在MASM中调用c的print

Assembly 在MASM中调用c的print,assembly,x86,printf,masm,masm32,Assembly,X86,Printf,Masm,Masm32,我尝试使用C print方法打印字符串,但它不打印任何内容。我可以打印数字,但当我尝试使用字符串时,它不起作用 .386 .model flat, stdcall .stack 200h option casemap :none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\user32.inc includelib \masm32\lib\kern

我尝试使用C print方法打印字符串,但它不打印任何内容。我可以打印数字,但当我尝试使用字符串时,它不起作用

.386
.model flat, stdcall
.stack 200h
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
include \masm32\include\masm32rt.inc
dll_dllcrt0 PROTO C
printf PROTO C :VARARG

.DATA
_foo DB "String Contents",0

.CODE

START:


invoke printf, cfm$("%s"),_foo

END START 

正如Jester所说,使用偏移量而不是工作量。这就解决了问题

...
invoke printf, cfm$("%s"),OFFSET _foo
...

只是猜测,但试着用
OFFSET\u-foo
代替。另外,最好在末尾加一个换行符,以避免任何缓冲问题。这就解决了问题,谢谢。如何将问题标记为“已解决”?为您自己的问题添加一个答案,然后在几天内您可以接受您自己的答案。