0

for a Project at University I need to make small Assembly programs. And for one of those I need to check if the arguments are palindromes. (abba = palindrome / acba = no palindrome)

I have nearly everything but I kind of have a problem with comparing. I planed to have the string in rsi and rax. Then move with inc rsi from one side and with dec rax from the other side comparing in each step the characters.

But I think that somehow my rax is empty or the add rax, rdx doesnt put the Pointer at the end of the string.

eos_found:
    pop rsi     ; restore starting address of string
    push rdx    ; store length of string
    push rsi
    push rsi
    pop rax

    add rax, rdx ;pointer points to the end of the string   

cmp_strings:
    cmp [rsi], byte 0
    je is_palindrome

    mov al, [rax]
    cmp [rsi], al
    jne not_palindrome

    inc rsi
    dec rax
    jmp cmp_strings

Moe
  • 1
  • 2
  • 2
    `al` is a part of `rax`. So, `mov al, [rax]` does not only change `al` but also `rax`. – rkhb Jan 08 '20 at 13:21
  • 1
    rax is a 64 bit register. al is simply the lowest byte of rax. You are overwriting rax in this instruction *mov al, [rax]*. Maybe use bl here :). The instruction would look like this then: *mov bl,[rax]*, followed by *cmp [rsi],bl* – Suraaj K S Jan 08 '20 at 13:24

0 Answers0