小弟我想用在C中调用汇编完成a+b的功能,但是不知道有关问题出在哪儿了,求指点
我想用在C中调用汇编完成a+b的功能,但是不知道问题出在哪儿了,求指点
------解决方案--------------------
- C/C++ code
#include <stdio.h> #include <stdlib.h> char str1[] = "%d %d\n"; char str2[] = "%d\n"; int a = 0,b = 1; int main() { _asm { mov eax,offset a push eax mov eax,offset b push eax mov eax,offset str2 call scanf pop ebx pop eax mov a,eax pop eax mov b,eax mov eax,a push eax mov eax,b push eax mov eax,offset str1 push eax call printf pop ebx pop ebx pop ebx } return 0; }
------解决方案--------------------
- C/C++ code
#include <stdio.h> #include <stdlib.h> int main() { char str1[] = "%d %d"; char str2[] = "%d\n"; int a = 0,b = 1; __asm { pushad lea eax, a push eax lea eax, b push eax lea eax, str1 push eax call scanf_s add esp, 0xC mov eax, a add eax, b push eax lea eax, str2 push eax call printf_s add esp, 0x8 popad } system("pause"); return 0; }