Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

_start: ldr r0, =in_file_name @ Open up the file mov r1, #0 @ Read only swi SWI_Open bcs file_not_found ldr r1, =file_handle @ Save the

_start: ldr r0, =in_file_name @ Open up the file mov r1, #0 @ Read only swi SWI_Open bcs file_not_found ldr r1, =file_handle @ Save the file handle for later str r0, [r1]

@ ======================================== @ Read each line of the file into a buffer. @ ======================================== get: ldr r0, =file_handle @ Read the next line of input ldr r0, [r0] ldr r1, =line mov r2, #LINE_SIZE swi SWI_ReadS @ I SWI_ReadS gives the bcs end_of_file @ number of bytes read in R0. subs r0, r0, #1 @ But counts the newline. beq end_of_file @ If the line was empty we'll stop. @ ======================================== @ Here is where you put YOUR part of the assignment. @ @ If the string passes the test, branch to "good", and if it @ does not, branch to "bad". @ ========================================

@ ============================================================ @ @ need help @ @ ============================================================ good: mov r0, #1 @ Print that it is ldr r1, =it_is @ Experienced ARM people swi SWI_WriteS @ Would make the LDR here b get @ Conditional and save steps.

bad: mov r0, #1 @ Print that it is not ldr r1, =it_is_not swi SWI_WriteS b get

end_of_file: ldr r0, =file_handle @ Close the file, stop the program ldr r0, [r0] swi SWI_Close swi SWI_Exit

file_not_found: mov r0, #1 @ Stdout ldr r1, =in_file_error swi SWI_WriteS swi SWI_Exit

@ ============================================================ @ @ Data @ @ ============================================================

.data .align 4 file_handle: .word 0x00 in_file_name: .asciz "PAL.TXT" in_file_error: .asciz "Can't open the file. Shoot... " it_is_not: .asciz "This was not a palindrome. " it_is: .asciz "YES! This one IS a palindrome! " line: .skip LINE_SIZE @ The line will be read into here newline: .asciz " "

Palindrome assembly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions