我一直在编写一个简单的 c++ 程序,它使用 Assembly 获取 2 个数字的 GCD 并将它们作为我观看的教程中使用的示例输出。我明白它在做什么,但我不明白为什么它不起作用。编辑:应该在运行时添加它,它根本不输出任何东西。
#include <iostream>
using namespace std;
int gcd(int a, int b)
{
int result;
_asm
{
    push ebp
    mov ebp, esp
    mov eax, a
    mov ebx, b
looptop:
    cmp eax, 0
    je goback
    cmp eax, ebx
    jge modulo
    xchg eax, ebx
modulo:
    idiv ebx
    mov eax, edx
    jmp looptop
goback:
    mov eax, ebx
    mov esp, ebp
    pop ebp
    mov result, edx
}
return result;
}
int main()
{
cout << gcd(46,90) << endl;
    return 0;
}
我在 32 位 Windows 系统上运行它,任何帮助将不胜感激。编译时出现4个错误:
warning C4731: 'gcd' : frame pointer register 'ebp' modified by inline assembly code
warning C4731: 'gcd' : frame pointer register 'ebp' modified by inline assembly code
warning C4731: 'main' : frame pointer register 'ebp' modified by inline assembly code
warning C4731: 'main' : frame pointer register 'ebp' modified by inline assembly code