So I am using C++ with assembly to do 16-bit signed multiplication.
I know that for 16-bits, the multiplicand is AX and the multiplier is either a register or memory operand 16 bit with the product being stored in EDX:EAX which is twice the size of operands.
I am a beginner so I tried first with 8 bit signed multiplication in which it works:
#include "stdafx.h"
#include <stdio.h>
int main()
{
char X, Y;
short Z;
_asm
{
MOV X, 5
MOV Y, 11
MOV AL, X
MOV BL, Y
IMUL BL
MOV Z, AX
}
printf("The result times is = %i", Z);
getchar();
//system("pause");
return 0;
}
but I'm unsure why the following code wouldn't work for 16 bit instead.
#include "stdafx.h"
#include <stdio.h>
int main()
{
short X, Y;
int Z;
_asm
{
MOV X, 5
MOV Y, 11
MOV AX, X
MOV BX, Y
IMUL BX
MOV Z, [DX::AX]
}
printf("The result times is = %i", Z);
getchar();
//system("pause");
return 0;
}