【发布时间】:2011-09-09 18:15:27
【问题描述】:
我在 Visual c++ 2010 Ultimate (Windows 7 Professional) 中遇到内联汇编问题。我所有的内联程序集都不起作用,当我使用字符、DWORD 字符串等时......所以我从 MSDN 复制了这段代码到我的控制台应用程序中:
// InlineAssembler_Calling_C_Functions_in_Inline_Assembly.cpp
// processor: x86
#include <stdio.h>
char format[] = "%s %s\n";
char hello[] = "Hello";
char world[] = "world";
int main( void )
{
__asm
{
mov eax, offset world
push eax
mov eax, offset hello
push eax
mov eax, offset format
push eax
call printf
//clean up the stack so that main can exit cleanly
//use the unused register ebx to do the cleanup
pop ebx
pop ebx
pop ebx
}
}
我的应用程序中除了这些行之外什么都没有,结果:字符串没有被打印并且应用程序崩溃。任何想法为什么会发生这种情况?
【问题讨论】:
标签: visual-c++ assembly inline-assembly