Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would this code be finished? Its MIPS assembly language made in PLP Software Tool 5.2. I have initialized everything the code just needs finished.

How would this code be finished? Its MIPS assembly language made in PLP Software Tool 5.2. I have initialized everything the code just needs finished. Can someone complete the code so it functions as a palindrome checker? Thank you! image text in transcribed
image text in transcribed
image text in transcribed
The Task In this project, you will be writing a program that receives a string of characters via the UART, checks if this string is a palindrome, and then uses a print function to print either "Yes" or "No". A palindrome sequence of characters (typically a word or phrase) that is the same both forwards and backwards. For this project, strings will be terminated using a period ('). You may assume that a string will contain at least one character in addition to a period. You will not need to handle empty strings or strings with only a period. Your program should be able to handle multiple strings sent one after another or concatenated together. For example, the string: "abba. data." should print "Yes" followed by "No" on the next line. Spaces should be ignored when checking for a palindrome and the palindrome should not be case sensitive. For example, "A nut for a jar of Tuna." would be considered a palindrome. Print Function A skeleton PLP project file is available to download on Blackboard. The PLP project includes a second ASM file titled, project3_print.asm. This ASM file contains the print function used in this project. PLPTool concatenates all ASM files within a PLP project into a single location in memory (unless additional .org statements have been added to specify different location for code). No changes to project3_print.asm should be made When called, depending on the value in register Sao, the following string will be displayed on the simulated UART device's output. If Sao contains a zero then "No" will be displayed and if Sao contains a non-zero value (e.g. one) then "Yes" will be displayed. The print function is called using the following instruction: call project3 print To use the print function, your PLP program needs to initialize the stack pointer ($sp) before performing the unction call (or any other operations involving the stack pointer). For this reason, the skeleton project file ncludes an initialization that sets the stack pointer to 8x10fffffc (the last address of RAM). Palindrome Checking Strategies There are two strategies I would recommend for saving your string in in memory and checking to see if it is a palindrome. The first would be to use only an array and keep a pointer (a register containing a memory address) for both the first element in the array (commonly referred to as a head pointer) and last element in the array (commonly referred to as a tail pointer). As you add elements to your array, update your tail pointer so that it moves to the new last element in the array. When you have reached the end of your string (a period has been received), you can perform your palindrome check comparing the characters your head and tail pointers point to and, if they point to the same character, move them both inwards towards the center of your array. If the pointers cross and all the characters were the same, your string was a palindrome. The second strategy would be to use an array, treated as a queue, and the stack. You can traverse the array from the start (the first character saved) to the end (the last character saved) while simultaneously popping characters off the stack. The queue will give you the string forwards and the stack will give you the string backwards. For both techniques I described above, keep in mind they are simpler if you perform some conditioning to the characters you receive before saving them. For example you don't need to save spaces in your data structure(s) since they can be ignored and the comparisons are simpler if, when first receiving character, you convert them all to the same case (either all upper or all lower) before storing them. That way you won't need to write logic that indicates things like "A--"a" and "A-22 "a". Deliverables 1. 2. 3. Take the Project 3 Pre Quiz (6 points) Submit your program on Canvas with the format: Firstname Lastname_project3.plp (21 points) Take the Project 3 Post Quiz (3 point) Source Files 0: main.asm 5 Ili ssp, ex10fffffc 6 li st8, 8xF0080800 1: project3 print.asm Meta Information 8 li st6, 0b80101110 meta DIRTY ISA-PLPCPU 10 11 main 12 nop 14 array ptr: 16 17 18 nain: .space 100 Li $se, array_ptr nove $s1, $se 21 read UART lw $t1, 4(ste) and $t2, $t1, $t9 bne $t2, s8 rx j main 32 lw $t3, 8(Ste) beq t3, $t6 period and $t2, $t3, st5 beq $t2, se go low beq $t3, $t5 empty 37 nop 42 nop 43 44 nop 45 period: addiu $se, sse, 4 1 palindrone 5e nop go low: addiu $t3, $t3, 32 1 array 5 Inop Assembling The Task In this project, you will be writing a program that receives a string of characters via the UART, checks if this string is a palindrome, and then uses a print function to print either "Yes" or "No". A palindrome sequence of characters (typically a word or phrase) that is the same both forwards and backwards. For this project, strings will be terminated using a period ('). You may assume that a string will contain at least one character in addition to a period. You will not need to handle empty strings or strings with only a period. Your program should be able to handle multiple strings sent one after another or concatenated together. For example, the string: "abba. data." should print "Yes" followed by "No" on the next line. Spaces should be ignored when checking for a palindrome and the palindrome should not be case sensitive. For example, "A nut for a jar of Tuna." would be considered a palindrome. Print Function A skeleton PLP project file is available to download on Blackboard. The PLP project includes a second ASM file titled, project3_print.asm. This ASM file contains the print function used in this project. PLPTool concatenates all ASM files within a PLP project into a single location in memory (unless additional .org statements have been added to specify different location for code). No changes to project3_print.asm should be made When called, depending on the value in register Sao, the following string will be displayed on the simulated UART device's output. If Sao contains a zero then "No" will be displayed and if Sao contains a non-zero value (e.g. one) then "Yes" will be displayed. The print function is called using the following instruction: call project3 print To use the print function, your PLP program needs to initialize the stack pointer ($sp) before performing the unction call (or any other operations involving the stack pointer). For this reason, the skeleton project file ncludes an initialization that sets the stack pointer to 8x10fffffc (the last address of RAM). Palindrome Checking Strategies There are two strategies I would recommend for saving your string in in memory and checking to see if it is a palindrome. The first would be to use only an array and keep a pointer (a register containing a memory address) for both the first element in the array (commonly referred to as a head pointer) and last element in the array (commonly referred to as a tail pointer). As you add elements to your array, update your tail pointer so that it moves to the new last element in the array. When you have reached the end of your string (a period has been received), you can perform your palindrome check comparing the characters your head and tail pointers point to and, if they point to the same character, move them both inwards towards the center of your array. If the pointers cross and all the characters were the same, your string was a palindrome. The second strategy would be to use an array, treated as a queue, and the stack. You can traverse the array from the start (the first character saved) to the end (the last character saved) while simultaneously popping characters off the stack. The queue will give you the string forwards and the stack will give you the string backwards. For both techniques I described above, keep in mind they are simpler if you perform some conditioning to the characters you receive before saving them. For example you don't need to save spaces in your data structure(s) since they can be ignored and the comparisons are simpler if, when first receiving character, you convert them all to the same case (either all upper or all lower) before storing them. That way you won't need to write logic that indicates things like "A--"a" and "A-22 "a". Deliverables 1. 2. 3. Take the Project 3 Pre Quiz (6 points) Submit your program on Canvas with the format: Firstname Lastname_project3.plp (21 points) Take the Project 3 Post Quiz (3 point) Source Files 0: main.asm 5 Ili ssp, ex10fffffc 6 li st8, 8xF0080800 1: project3 print.asm Meta Information 8 li st6, 0b80101110 meta DIRTY ISA-PLPCPU 10 11 main 12 nop 14 array ptr: 16 17 18 nain: .space 100 Li $se, array_ptr nove $s1, $se 21 read UART lw $t1, 4(ste) and $t2, $t1, $t9 bne $t2, s8 rx j main 32 lw $t3, 8(Ste) beq t3, $t6 period and $t2, $t3, st5 beq $t2, se go low beq $t3, $t5 empty 37 nop 42 nop 43 44 nop 45 period: addiu $se, sse, 4 1 palindrone 5e nop go low: addiu $t3, $t3, 32 1 array 5 Inop Assembling

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions