another question on assembly.
i'm having problems with inline assembly.
assignment.cpp(27) : error C2443: operand size conflict
assignment.cpp(28) : error C2443: operand size conflict
assignment.cpp(29) : error C2443: operand size conflict
my code is the following
Code:
#include<iostream>
using namespace std;
int sum(int a,int b);
int main()
{
int a=0,b=0,num=0;
cout<<"enter integer";
cin>>a;
cout<<"enter integer";
cin>>b;
num = sum(a,b);
cout << num;
return 1;
}
int sum(int a, int b)
{
int n=0;
//it doesn't like my inline block here
//i'm assuming it means that the integers a, b, n differ in size from the ah register.
//how would i fix this? cast?
_asm
{
mov ah, a
add ah, b
mov n, ah
}
return n;
}
So, I figured it out. I used short instead of int, and it worked.