回文を見つけるためのコードを書きました。しかし、私のコードは、すべてのケースで「回文ではない」という出力を示しています。私のプログラムは次のとおりです。
section .data
a db "mommom",0
b equ $-a
msg1 db "is pallindrome",10,0
msg2 db "is not pallindrome",10,0
msg3 db "",10,0
section .text
global main
extern printf
main:
nop
xor eax,eax
xor ebx,ebx
mov eax,a ;starting add
mov ebx,b
add eax,ebx
dec eax ;will use to indicate the last letter of a
xor ebx,ebx
xor edx,edx
xor ecx,ecx
start:
inc ecx
cmp ecx,(b/2) ;check will run for half of the word
jle check
jmp pal
check:
mov dl,byte[eax] ;last letter
cmp byte[a+ebx],dl ;frst letter compares with last letter
debug:
pusha ;debugging purpose.Used to catch the first letter of a
push byte[a+ebx]
push msg3
call printf
add esp,8
popa
checkContinue:
inc ebx ;use for check segment
dec eax
je start
jne nonPal
pal:
pusha
push msg1
call printf
add esp,4
popa
jmp done
nonPal:
pusha
push msg2
call printf
add esp,4
popa
jmp done
done:
nop
Antoine Mathys は、上記のコードの適切なバージョンを既に提供しており、このコードで発生した間違いを指摘しています。彼の発言セクションは、初心者のような私たちにとって非常に重要です. ここで、上記のプログラムで、ebx レジスターにあるすべての文字を出力しようとしましたが、それを取得できませんでした。問題のこの部分にアプローチできるメンターがいるとありがたいです。文字列から各文字を取得する方法を学ぶのに役立ちます。