我用masm32编写了一个复制字符串过程
coppystring proc uses esi edi ecx source:dword,dest:dword
mov esi, OFFSET source
mov edi, OFFSET dest
mov ecx, SIZEOF source
Lx:
mov al,[esi]
mov [edi],al
inc esi
inc edi
loop Lx
coppystring endp这段代码给了我错误
用于偏移量的A2098无效操作数
偏移运算符后面的表达式必须是内存表达式或立即表达式。但我还是不知道怎么修正我的程序
发布于 2016-12-31 19:44:08
您得到这些错误是因为在编译时不知道source和dest的内存地址。你需要把地址传递给牧师。此外,正如注释所指出的,您不能使用SIZEOF,应该检查空终止符,或者以另一种方式获取长度。
invoke coppystring,offset str1,offset str2 ; Push the offsets here
coppystring proc uses esi edi source:dword,dest:dword
; Generally only need to preserve esi, edi and ebx
mov esi, source
mov edi, dest
Lx:
mov al,[esi]
mov [edi],al
inc esi
inc edi
cmp byte ptr [esi],0 ; Check for null terminator
jne Lx ; loop if not null
ret
coppystring endphttps://stackoverflow.com/questions/41324841
复制相似问题