Question
Write a program to check if a given string is a palindrome. You are free to implement an algorithm of your own but a recommended
Write a program to check if a given string is a palindrome. You are free to implement an algorithm of your own but a recommended approach is given in the next section. Study the logic in the pseudocode and think of how it is implemented in NASM...
UPDATE 4/30/18 Small but significant bugs removed from Pseudocode
------------------------------------------
C-Style Pseudocode is given below:
print(The string is: "); // output Msg1 print(string1); // output the string that is being checked print(nl); // output new line character // get string length stringLength = 0; edi = &string1; checkNextChar: if( *edi == null ) GOTO countFinished; else{ edi++; stringLength++; GOTO checkNextChar }
countFinished: edi = &string1 esi = &string1 esi = esi + stringLength esi--; COMPARE_LETTERS:
ah = *edi; al = *esi; if(ah != al) GOTO NOT_PALINDROME else{ edi++; esi--; if(edi >= esi) GOTO IS_PALINDROME GOTO COMPARE_LETTERS: }
IS_PALINDROME: print(string1); print(" IS a palindrome); print(nl); exit(0);
NOT_PALINDROME: print(string1); print(" is NOT a palindrome); print(nl); exit(0);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started