[英]16 bit MUL assembly
On x86 16-bit assembly, if there is a 1
in ax
and 0x10
( 16
) in cl
, the following code doesn't put 0x1000
in cl
: 在x86 16位汇编程序上,如果
ax
在a中为1
,在cl
0x10
( 16
),则以下代码不会在cl
放入0x1000
:
mul cl ; ax = 0x 10
mul cl ; ax = 0x 100
mul cl ; ax = 0x0000 (not 0x1000)
Why doesn't this code work as expected? 为什么此代码无法按预期工作?
Your source is 8 bits ( cl
) so the multiplication is performed over al
only. 您的源是8位(
cl
),因此乘法仅在al
上执行。
Use mul cx
instead. 请改用
mul cx
。
Explanation: If ax = 100h
, then al = 00h
. 说明:如果
ax = 100h
,则al = 00h
。 Since the result of mul cl
is placed in ax
, what you do is basically to replace the content of ax
with 00h*cl
, which is 00h
. 由于
mul cl
的结果放在ax
,因此您要做的基本上是用00h*cl
替换ax
的内容,即00h
。
Opcode MUL
操作码MUL
CPU: i8086+ Type of Instruction: User
CPU:i8086 +指令类型:用户
Affected FLags: CF, OF, AF, PF, SF, ZF
受影响的标志:CF,OF,AF,PF,SF,ZF
Instruction: MUL src
说明:MUL src
Note: Unsigned multiply of the accumulator by the source.
注意:累加器与源的无符号乘法。 If "src" is a byte value, then AL is used as the other multiplicand and the result is placed in AX.
如果“ src”是字节值,则将AL用作另一个被乘数,并将结果放在AX中。 If "src" is a word value, then AX is multiplied by "src" and DX:AX receives the result.
如果“ src”是单词值,则将AX乘以“ src”,然后DX:AX接收结果。 If "src" is a double word value, then EAX is multiplied by "src" and EDX:EAX receives the result.
如果“ src”是双字值,则将EAX乘以“ src”,然后EDX:EAX接收结果。 The 386+ uses an early out algorythm which makes multiplying any size value in EAX as fast in the 8 or 16 bit registers.
386+使用早期算法,可以使EAX中的任何大小值在8或16位寄存器中快速相乘。
++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++
Clocks (i486): MUL reg8 13-18 MUL reg16 13-26 MUL reg32 13-42 MUL mem8 13-18 MUL mem16 13-26 MUL mem32 13-42时钟(i486):MUL reg8 13-18 MUL reg16 13-26 MUL reg32 13-42 MUL mem8 13-18 MUL mem16 13-26 MUL mem32 13-42
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.