I run this code, which is called from a C++ program that just accepts input for the integers num1 and num2 and passes them to sum.asm. I get the errors: A2022: instruction operands must be the same size in sum.asm line 5 MSB3721: The command "mI64.exe/c/nologo /Zi/Fo "x64\Debug\sum.obj" /W3 /errorReport:prompt /Ta" ......\OneDrive\Documents\sum.asm"" exited with code 1. in masm.targets line 70
I tried changing
mov rax, eax
to
movq rax, [eax]
because I saw that was like one of the answers to another question like mine, but it gave me another error saying it wasn't the right syntax
main.cpp:
#include <iostream>
extern "C" int sum (int num1, int num2);
int main() {
int num1, num2, answer;
std::cout << "Enter num1:" << std::endl;
std::cin >> num1;
std::cout << "Enter num2:" << std::endl;
std::cin >> num2;
answer = sum(num1, num2);
std::cout << num1 << "+" << num2 << "=" << answer << std::endl;
return 0;
}
sum.asm:
_sum PROC
mov eax, ecx
add eax, edx
mov rax, eax
ret
_sum ENDP
END
This is just supposed to add the 2 numbers passed in from the main c++ project and then return the sum.