StrReverse proc
uses ecx eax edi esi,
StrAdd1:dword, ;string 1 address
StrAdd2:dword ;string 2 address
std ;backward direction - set direction flag
push StrAdd2 ;address of str2 arg to StrlenAsm
call StrLenAsm ;get length of str2
;called function responsible for stack cleanup
mov ecx,eax ;length of string in ecx for rep
mov edi,StrAdd1 ;edi gets destination address for copy
mov esi,StrAdd2 ;esi gets source address for copy
loopTop:
lodsb ;
stosb ;
loop loopTop
mov byte ptr[edi],0 ;null terminate copied string
ret ;return control to caller
StrReverse endp
我知道STD
这会造成麻烦,但我想如果我想反转字符串,我应该使用std
...有人可以向我解释为什么这是错误的并给出如何解决它的提示吗?
感谢您提供任何进一步的帮助!
编辑:所以像这样?
StrReverse proc
uses ecx eax edi esi, ;
StrAdd1:dword, ;string 1 address
StrAdd2:dword ;string 2 address
push StrAdd1 ;address of str2 arg to StrlenAsm
call StrLenAsm ;get length of str2
;called function responsible for stack cleanup
mov ecx,eax ;length of string in ecx for rep
mov edi,StrAdd1 ;edi gets destination address for copy
mov esi,StrAdd2 ;esi gets source address for copy
add edi, ecx
loopTop:
cld ;forword direction - clear direction flag
lodsb ;read from source string
std ;backward direction - set direction flag
stosb ;write into distination string
loop loopTop
mov byte ptr[edi],0 ;null terminate copied string
ret ;return control to caller
StrReverse endp
它仍然崩溃=[