【发布时间】:2023-03-08 21:39:01
【问题描述】:
我在执行下面的代码时遇到问题
unique proc
invoke lstrlen, esi
cmp eax, 1
jle quit
mov ebx, 0; previous iterator
mov edx, 0; next iterator
dec eax
mov ecx, eax
inc eax
next:
inc edx
cmp [esi][ebx], [esi][edx]
je skip
cmp
inc ebx
cmp ebx, edx
dec ebx
je skip
inc ebx
mov [esi][ebx], [esi][edx]
skip:
loop next
mov [esi][edx], '0'
quit:
ret
unique endp
我在这里使用间接寻址,所以我希望
cmp [esi][ebx], [esi][edx]
替换为
cmp ds:[esi][ebx], ds:[esi][edx]
我哪里错了?
【问题讨论】:
-
在同一条指令中不能有多个内存操作数。
-
@fuz,如果寄存器 ebx 中有地址,寄存器 edx 中有移位,如何获取元素?
-
您可以像这样使用
mov指令:mov al, [esi][ebx]。虽然使用movzx会稍微快一些:movzx eax, [esi][ebx]。大多数指令最多支持一个内存操作数。您的比较结果如下所示:movzx eax, [esi][ebx]; cmp al, [esi][edx]. -
尝试使用两个内存操作数基本上是Why isn't movl from memory to memory allowed?的重复。我的回答确实显示了
[reg+reg]语法。还有Referencing the contents of a memory location. (x86 addressing modes) 用于寻址模式语法。
标签: assembly x86 masm tasm addressing-mode