SO guys I am supposed to be making a program that will check for a palindrome but, I can not get my code to work. It seems to be stuck on the cmp part. I am not sure if this is even right I dont have much experience with masm. Any help would much be appreciated

 segment .data
 s DB 'malayalam'
 s_size DW 9
 pal db "is a plaindrome",0x0a,0

segment .text
global main
extern printf
main:


 lea rdi, [s]               ;move string into rsi
 mov rsi, rdi               ;set rsi to rdi
 add rsi, s_size            ;add the 9 to rsi
 dec rsi                    ;point to last charecter

 mov rcx, s_size            ;put 9 in rcx
 shr rcx, 1                 ; shift arithmetic right

 next_char:                 ;start loop 
 mov al, [rdi]              ; move rdi into al
 mov bl, [rsi]              ;move rdi into bl   ;**errors out right here*Emphasized Text Here***
 cmp al, bl                 ;compare al to bl 
 jne not_Palindrome         ;if the dont equal then go to not
 inc rdi                    
 dec rsi
 loop next_char


 is_Palindrome: ; print out "Palindrome!"
 ;**thecode below is how I was trying to print out my answer after the compare, I dont know if that is right**
 ;msg db "palindrome$"
 xor rbp,rbp
 xor rdi,rdi
 xor rsp,rsp
 xor rax,rax
push rbp
mov rbp , rsp
lea rdi , [pal]; parameter 1 for printf
xor rax , rax ;0 f loat ing po int parameters
call printf
xor rax , rax
 jmp end

  not_Palindrome: 
  ; print out "Not Palindrome!"
   ;**thecode below is how I was trying to print out my answer after the compare, I dont know if that is right**
 xor rbp,rbp
 xor rdi,rdi
 xor rsp,rsp
 xor rax,rax
push rbp
mov rbp , rsp
lea rdi , [pal]; parameter 1 for printf
xor rax , rax ;0 f loat ing po int parameters
call printf
xor eax , eax
end:
ret 

Edited 3 Years Ago by deceptikon: Added code tags

This should actually be coded in Yasm Haha, I have no idea what im doing here

lea rdi, [s] ;moves first characters of s into rdi, if s is 64-bit aligned. otherwise crashes

Maybe you meant to load the address of the first string byte into rdi?

This article has been dead for over six months. Start a new discussion instead.