简体   繁体   中英

MUL set the OF when it should not

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

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 .

由于符号,您必须使用IMUL而不是MUL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM