首页 文章

乘以bx和cx [ASM 8086]

提问于
浏览
0

我想将bx和cx相乘,但它不像我使用ax那样有效

mov ax,0AFh
mov cx,0AFh
mul cx

我尝试将bx和cx相乘

mov bx,Ah
mov cx,5h
mul cx
"???????"

为了乘以bx和cx,我想我必须使用临时寄存器 . 任何人都可以告诉我该怎么做?

1 回答

  • 0

    尝试一下:

    mov bx, 0Ah
    mov cx, 5h
    push ax
    mov ax, bx
    mul cx
    mov bx, ax
    pop ax
    ;at this point, ax is unchanged, result is in bx.
    

    或者,如果你想要花哨,试试这个:

    mov bx, 0Ah
    mov cx, 5h
    xchg ax, bx
    mul cx
    xchg ax, bx
    ;at this point, ax is unchanged, result is in bx.
    

    但是,乘以16位寄存器会将结果保留在 dx:ax 中 . 由于您的示例乘以小数字,这并不重要,因为整个结果将适合16位寄存器 . 但是,请注意,您的 dx 寄存器将被这些代码片段清除,如果您将来再乘以更大的数字,请务必在 dx:bx 中查找结果 .

相关问题