Reputation: 476
That's the problem: at the second mul
the overflow flag gets set to 1; the multiplication is a simple 120*(-6) = -720
, which is contained in 16 bits... I don't understand why.
.model small
.stack
.data
a dw 30
b dw 3
c dw -6
ris dw ?
.code
.startup
mov ax, a
mov bx, 4
mul bx
jo ove
mov bx, c
mul bx
jo ove
...
end
Upvotes: 2
Views: 159
Reputation: 212969
mul
is an unsigned multiply instruction, so you get an overflow because you are actually multiplying 120 * 65526. (Note that -6 signed = 0xfffa = 65526 unsigned.)
For signed multiplication you need imul
.
Upvotes: 5