Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Draw a detailed flowchart and write an ARM assembly program to determine whether

ID: 3726301 • Letter: D

Question

Draw a detailed flowchart and write an ARM assembly program to determine whether a string of printable ASCII letters (from a to z or from A to Z, case insensitive) stored in memory is a palindrome (i.e., the letters in the string are the same from left to right as from right to left, case insensitive) or not. If palindrome, you should store 1 in r0, if not, you store 2 in r0. Your code should be highly optimized. Use as few instructions as possible (as little as 21 assembly instructions only)!!.

Explanation / Answer

mov bl,50 ; Starting Address of the memory

mov dl,0 ; number of characters make up the string

loop:

in 00 ;read the input from keyboard

cmp al, 2E ;checking to see if input is a fullstop

jz palindrome ;loop to see if input is a palindrome

mov [bl], al ;save input in the memory address

inc bl ;goto the next memory addr in bl

inc dl ;increment dl by 1 to length of the string

push al

jmp loop

palindrome:

cmp dl,0 ;check if it has goes through whole string

jz is_palin ;loop it has then string is a palindrome

mov bl, 50 ;bring back first input character

mov dl,[bl]

pop cl ;put last input character

cmp cl,dl ;check if the two values are the same

jnz not_palindrome ;if they are not same,then loop to not_palindrome

inc bl ;go to next input address

dec dl ;take away 1 from length of the string

jmp palindrome ;loop back to the start of the palindrome

not_palindrome:

mov dl,c0

mov cl,6E

mov [dl],cl ;print the character "n" to the vdu

jmp done ; do not execute code at is_palin

is_palin:

mov dl,c0

mov cl,79

mov [dl],cl ;print the character 'y' to the vdu

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote