gpt4 book ai didi

assembly - 在 x86 汇编中是否可以用 mul 乘以立即数?

转载 作者:行者123 更新时间:2023-12-02 18:38:00 40 4
gpt4 key购买 nike

我正在使用 DosBox 模拟器学习 x86 的汇编。我正在尝试执行乘法。我不明白它是如何工作的。当我编写以下代码时:

mov al, 3
mul 2

我收到一个错误。尽管在我使用的引用文献中,它以乘法表示,但它假设 AX 始终是占位符,因此,如果我写:

mul, 2

它将 al 值乘以 2。但它对我不起作用。

当我尝试以下操作时:

mov al, 3
mul al,2
int 3

我在 ax 中得到结果 9。请参阅此图片以进行澄清: enter image description here

另一个问题:我可以直接使用内存位置进行乘法吗?示例:

mov si,100
mul [si],5

最佳答案

没有任何形式的 MUL 接受立即操作数。

要么:

mov al,3
mov bl,2
mul bl ; the product is in ax

或(立即数需要 186):

mov ax,3
imul ax,2 ; imul is for signed multiplication, but low half is the same
; the product is in ax. dx is not modified

或者:

mov al,3
add al,al ; same thing as multiplying by 2

或者:

mov al,3
shl al,1 ; same thing as multiplying by 2

关于assembly - 在 x86 汇编中是否可以用 mul 乘以立即数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20499141/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com