having a bit of trouble understanding assembly multiplication. Can anyone help break down the process of these steps:
mov ax,[p1000]; p1000 = +1000 ax = 03e8
imul [n100]; n100 = -100
_____________
-100,000
dx:ax = fffe 7960 (dx = fffe, ax = 7960) cf = 1
I’m not sure how to deduce that the answer is -100,000 from dx:ax. I’ve tried calculating it like so:
dx = (15 * 16^3) + (15 * 16^2) + (15 * 16) + 14 = 65,534
ax = (7 * 16^3) + (9 * 16^2) + (6 * 16) = 31,072
dx + ax = 96,606
I may be approaching this the wrong way, so please correct me if I am wrong.
will multiply and leave the result in dx:ax
Now, dx:ax = fffe 7960. This is a 32 bit quantity with the upper 16bits in dx and the lower 16bits in ax. Since the the MSB of this overall 32bit signed quantity is 1, it’s a negative number and we need the two’s compliment to find magnitude.
Convert that to decimal as usual (sum of all) (1*2^{bit_position}) … we get the magnitude as ..
100,000.
Now recall that it’s a negative signed number, (MSB = 1) so putting the sign and magnitude together we get … -100,000 🙂