g++:
1 /* 2 * Problem: 3 * Author: SHJWUDP 4 * Created Time: 2015/8/5 星期三 15:54:42 5 * File Name: tmp.cpp 6 * State: 7 * Memo: 8 */ 9 10 const int main_stack=16; 11 char my_stack[128<<20]; 12 13 void MAIN() { 14 //your code 15 } 16 17 int main() { 18 __asm__("movl %%esp, (%%eax);\n"::"a"(my_stack):"memory"); 19 __asm__("movl %%eax, %%esp;\n"::"a"(my_stack+sizeof(my_stack)-main_stack):"%esp"); 20 MAIN(); 21 __asm__("movl (%%eax), %%esp;\n"::"a"(my_stack):"%esp"); 22 return 0; 23 }
c++:
1 /* 2 * Problem: 3 * Author: SHJWUDP 4 * Created Time: 2015/8/5 星期三 15:54:42 5 * File Name: tmp.cpp 6 * State: 7 * Memo: 8 */ 9 #pragma comment(linker, "/STACK:1024000000,1024000000") 10 11 int main() { 12 return 0; 13 }