davidrobin
Programmer
I have a C program that calls this function
int Divide(int Firstnum,int Secondnum)
{
int Result;
asm
{
mov ax,Firstnum
mov bx,Secondnum
and bx,255
div bl
mov Result,ax
}
cout<<Result;
return Result;
} // end function
if I call the function like so
Divide(10,2)
The value 5 is returned as expected.
If I call the function with
Divide(3,2)
The value returned (and displayed) is 257, I would have expected the value returned to be 1 (ignoring the remainder). Can anyone enlighten me with this problem. The data types have to be integer, my lecturer says so.
David
Visual Basic 6 Ent
int Divide(int Firstnum,int Secondnum)
{
int Result;
asm
{
mov ax,Firstnum
mov bx,Secondnum
and bx,255
div bl
mov Result,ax
}
cout<<Result;
return Result;
} // end function
if I call the function like so
Divide(10,2)
The value 5 is returned as expected.
If I call the function with
Divide(3,2)
The value returned (and displayed) is 257, I would have expected the value returned to be 1 (ignoring the remainder). Can anyone enlighten me with this problem. The data types have to be integer, my lecturer says so.
David
Visual Basic 6 Ent