"Invalid combination of opcode and operands" x86 NASM 的 MUL 指令



我一直在使用x86 Assembly

我写的做幂的循环的当前状态是:

edi: temp resultesi:指数edx:原编号

mov esi, [y]
mov edi, [x]
mov edx, [x]
.powloop:
mul edi, edx
sub esi, 1
cmp esi, 0
jnz .powloop
ret

当我组装时,我得到这个错误:

main.asm:22: error: invalid combination of opcode and operands

22mul edi, edx所在的线

我做错了什么,有什么办法来解决这个问题?

mul指令不使用两个操作数。
mul指令强制使用EAX寄存器和另一个操作数。

您可以在EAX中加载原始号码。

; x^y
mov eax, [x]
mov esi, [y]
dec esi
jz  Done
More:
mul [x]
dec esi
jnz More
Done:

最新更新