// VarWidth.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
using namespace std;
int AddFunc(int x, int y) {
int a = 0, b = 0, c = 0;
cout << "x addr : " << &x << endl;
cout << "y addr : " << &y << endl;
cout << "a addr : " << &a << endl;
cout << "b addr : " << &b << endl;
cout << "c addr : " << &c << endl;
__asm{
mov eax, dword ptr[esp+4]
mov ebx, dword ptr[esp+8]
add eax, ebx
}
return 0;
}
int main(int argc, char* argv[])
{
int iRet = 0;
int x = 1, y = 2;
iRet = AddFunc(x, y);
// printf("Hello World!\n");
return 0;
}
Default 情況下 :
若是直接用 esp + offset Access Variable 的話, V$.net Debug Version 會用掉 12 Bytes, 如果 Debug / Release 都只要 4 Bytes 的話可以 follow 這一篇 : http://www.eggheadcafe.com/