#include <stdio.h>
int main()
{
int u=3;
char str[]="%d /r/n";
__asm
{
push u
lea eax, str //把str的地址给eax
//mov eax, offset str //会编译通不过,错误信息: error C2415: improper operand type
push eax
call printf
add esp, 8 //等价于调用两个pop eax ,因为有两个参数压栈
}
}
对应的汇编代码为:
9: __asm
10: {
11: push u
00401082 push dword ptr [ebp-4]
12: lea eax, str //把str的地址给eax
00401085 lea eax,[ebp-0Ch]
13: //mov eax, offset str //会编译通不过,错误信息: error C2415: improper operand type
14: push eax
0040108B push eax
15: call printf
0040108C call printf (00401ea0)
16: add esp, 8 //等价于调用两个pop eax ,因为有两个参数压栈
00401091 add esp,8
17: }
1. 内联汇编中调用