I have this code:
AREA palindrome, CODE, READONLY
SWI_Exit EQU 0x11
ENTRY
start
LDR r0,=string
MOV r1,r0
loop LDRB r2,[r1],#1
CMP r2,#0
BNE loop
SUB r1,r1,#2
BL pal
stop SWI SWI_Exit
pal MOV r10,#0x0
again LDRB r3,[r0]
LDRB r4,[r1]
CMP r3,r4
BNE notpal
CMP r0,r1
BEQ waspal
ADD r2,r0,#1
CMP r2,r1
BEQ waspal
ADD r0,r0,#1
SUB r1,r1,#1
B again
waspal MOV r0,#0x1
notpal MOV r0, #0x2
string DCB "abcba",0
END
But right now it only checks if it is a palindrome for strings that do not have any punctuation. I would like it so that when I enter a string with or without punctuation and spaces it stores 1 in r0 and 2 if it is not.
So right now when I enter:
"abcba"
I get that it is a palindrome, but when I have
"abc ba"
It is counted as not a palindrome.
Also I have this bug where it does not store any value in register 0 when finishing the loop. But if I change it so that I store the result in two different registers (one in r0 and one in r10) then it works.