0

I have the input sorted out for the palindrome program but I haven't got the slightest idea of how to check whether the inputted word is a palindrome or not.

; Program to read name and output greeting 
            BR  main 
        name:   .BLOCK 32           ;space for up to 32 characters 
    msg1:   .ASCII "The word is: \x00" 
    msg2:   .ASCII "Enter a word: \x00" 
    main:   LDX 0,i             ; load index register with 0
            STRO    msg2,d      ;output word prompt 
    chin:   CHARI   name,x          ;read a character 
            LDA name,x      ;and load accumulator 
            ADDX    1,I     ;add 1 to index register 
            CPA 0x0A00,i    ;compares with line feed 
            BREQ    out     ;if line feed go to out 
            BR  chin        ;go to chin to read next char 
    out:    LDA '\x00',I        ;load acc with end of string 
            STA name,x      ;store end of string in name block
            STRO    msg1,d      ;output word message 
            STRO    name,d      ;output stored name
            STOP 
    .END

Can someone help me out on this please? Thank you.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281

1 Answers1

2

Here's some simple C-ish pseudo-code to get you started:

Left = Start;
Right = Start + Length - 1;

while (Left <= Right)  
{
  if Word[Left] != Word[Right]
    not a palindrome, exit
  Left++;
  Right--;
}
palindrome
  • Could you throw me some mnemonics for me to mess around with? The ones that I need? If I have those I'm pretty sure I can do this then. – Hello World Nov 18 '15 at 19:10
  • @HelloWorld - you've already got a bunch of them in your question, use them (and your own head) – enhzflep Nov 18 '15 at 23:13