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
}
}
私は自分のアプリケーションでこれらの行を除いては何もありません、結果:文字列が印刷されず、アプリケーションがクラッシュします。これがどうして起こるのか?
なぜ 'printf'がアクセス違反を引き起こしているのか分かりませんが、最初の3つの引数(' eax'を最初に読み込む必要はありません)を押してから、問題を再現できます。関数呼び出し、つまり 'eax'へのポップアップはありません。 'printf'はまだクラッシュします。 ' –
これは理由ではありませんが、この答えはまだ確実に_future_クラッシュを避ける非常に重要なものを追加します。 +1 – BlackBear