我正在从Paul caurter 的 PC Assembly 中学习 80386
mul source
- 如果操作数是字节大小的,则将其乘以 AL 寄存器中的字节,并将结果存储在 AX 的 16 位中。
美好的。
- 如果源是 16 位,则乘以 AX 中的字,并将 32 位结果存储在 DX:AX 中。
Q1:为什么选择 DX:AX ?为什么不能存储在 EAX / EDX 中?
imul
真的很混乱
imul dest, source1
imul dest, source1, source2
我在理解表格时遇到了问题。
Q2:在表格的第二个条目中。再次,为什么选择 DX:AX。为什么不是 EAX 或 EDX?
现在考虑以下代码片段:
imul eax ; edx:eax = eax * eax
mov ebx, eax ; save answer in ebx
mov eax, square_msg ; square_msg db "Square of input is ", 0
call print_string ; prints the string eax
mov eax, ebx
call print_int ; prints the int stored in eax
call print_nl ; prints new line
Q3:之前说的The notation EDX:EAX means to think of the EDX and EAX registers as one 64 bit register with the upper
32 bits in EDX and the lower bits in EAX.
那么答案也存储在edx中吧?在上面的代码中,我们没有考虑任何 EDX,我们只是指 EAX 这仍然有效吗?
Q4:我对表中所有条目的其余部分有疑问。两个 n 位数字(n = 8/16/32 位)的最坏情况相乘结果为 2n 位。它如何将两个 16/32 位乘法结果存储在相同大小的寄存器中?