。我到目前为止已经呆了几天,尽管在这个站点上浏览了所有其他针对此确切问题的答复,但我仍无法弄清楚我在做什么错。谁能为我提供一些帮助?出于某种原因,当我分别使用[esi]和[edi]将每个字符串的值移动到al和dl中时。最终比较这些val时,它们始终设置为零标志,而不管这些值是否相等]
BufSize = 80
.data
msg BYTE "Input a string for reversal: ",0
msg1 BYTE "palindrome",0
msg2 BYTE "not palindrome",0
buffer BYTE BufSize DUP(?),0,0
bytesRead DWORD ?
string1 DWORD ?
string2 DWORD ?
TEMP1 DW 0
PALMESSAGE DB " THE PROVIDED STRING IS A PALINDROME $"
NOTPALMESSAGE DB " THE PROVIDED STRING IS NOT A PALINDROME $"
.CODE
main proc
; Wait for user input
mov edx, OFFSET buffer
mov ecx, SIZEOF buffer
call ReadString
mov bytesRead, eax
mov string1, edx
mov ecx, bytesread
mov esi,0
COMPARE:
MOVZX EAX, buffer[esi]
push eax
inc esi
LOOP COMPARE
mov ecx,bytesRead
mov esi,0
L2:
pop eax ; get character
mov buffer[esi],al ; store in string
inc esi
Loop L2
mov string2, offset buffer
mov ecx, bytesread
mov edx, string2
call writestring
mov ecx,bytesRead
mov esi,0
mov edi,0
;mov eax,0
;mov edx,0
mov esi, string1
mov edi, string2
L3:
mov al, [esi]
mov dl, [edi]
cmp al,0 ; end of string1?
jne L4 ; no
cmp dl,0 ; yes: end of string2?
jne L4 ; no
jmp pal ; yes, exit with ZF = 1
L4:
inc esi ; point to next
inc edi
cmp al,dl ; characters equal?
je L3 ; yes: continue loop
jmp notpal ; no: exit with flags set
PAL:
mov edx, OFFSET msg1
call WriteString
call crlf
JMP FIN
NOTPAL:
mov edx, OFFSET msg2
call WriteString
call crlf
FIN:
exit
main ENDP
END main
。我到目前为止已经呆了几天,尽管在这个站点上浏览了所有其他针对此确切问题的答复,但我仍无法弄清楚我在做什么错。谁能提供我...
看起来您为反向字符串使用了与初始输入相同的缓冲区。 string1与string2拥有相同的指针。因此,它们当然比较相等。至少这是一个很好的信号,表明您其余的代码可能正在运行。