UART Palindrome checker

User Generated

FnawvFracnv

Programming

Description

I need help with array_ptr and poll_UART asap.

Unformatted Attachment Preview

CSE 230 Project 3: UART Palindrome Checker Learning Objectives: ● Create modular code and interface with unfamiliar modularized code 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 is a 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 letter in addition to a period (e.g., the input, “b.”, should be considered a palindrome). You will not need to handle empty strings, strings containing only a period, or stings containing characters other than letters, spaces, and periods. 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 Canvas. 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 $a0, the following string will be displayed on the simulated UART device’s output. If $a0 contains a zero then “No” will be displayed and if $a0 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 function call (or any other operations involving the stack pointer). For this reason, the skeleton project file includes an initialization that sets the stack pointer to 0x10fffffc (the last address of RAM). Skeleton Code Structure The skeleton code contains six function stubs that need to be implemented. Five are called from the main loop and one needs to be implemented as a nested function call. The skeleton code contains comments with descriptions of what each function needs to do and how it should be implemented. The table below provides a brief description of the functions. Function Name poll_UART period_check space_check case_check array_push palindrome_check Function Description Polling loop for UART’s status register, reading new character, and indicating character has been read Checks if new character is a period and makes a nested function call to palindrome_check if it is Skips saving space characters to array Converts new character to uppercase if it is lowercase Saves new character to array Moves inwards from front and back of array and compares characters at each step to determine if the string is a palindrome. If at any point mirroring characters are not equal, then it should use the print function to print “No”. If the comparison reaches or passes the midpoint then the print function should be used to print “Yes”. Debugging Tools To show that you properly tested your program, please save your program while it is in simulation mode (the blue simulation mode button has been toggled on) such that a CPU Memory Visualization window is open and shows at least the first 6 words of memory in the array. Please keep in mind that the starting address of the array is relative to the number of initializations placed before the assembler directive allocating space for the array. If you change your initializations you may need to adjust your CPU Memory Visualization base address. The Array Example video in this project’s module demonstrates how to set up a CPU Memory Visualization window. It is acceptable to also see program contents in memory (these cells will be colored blue). For example, it would be acceptable to see the following in the visualizer after the string, “abcd.”, has been sent by the user. Additionally, the watcher window should contain, at minimum, registers $v0, $s1, and $s2. You are include any other registers in the watcher window that you find useful for debugging. Points will be deducted if a CPU Memory Visualization window configured to show the start of the array does not open when simulation mode is toggled on or the watcher window does not include the minimum set of registers (the watcher window does not need to open when simulation mode is toggled on). Deliverables: 1. Take the Project 3 Pre Quiz (6 points) 2. Submit your program on Canvas with the format: Firstname_Lastname_project3.plp (21 points) 3. Take the Project 3 Post Quiz (3 point) Skeleton file: .org 0x10000000 # Initializations li $sp, 0x10fffffc # Starting address of empty stack li $s0, 0xf0000000 # UART base address li $s1, array_ptr # Array head pointer li $s2, array_ptr # Array tail pointer j main nop array_ptr:# Label pointing to 100 word array .space 100 main: jal poll_UART nop jal period_check nop jal space_check nop jal case_check nop jal array_push nop j main nop # The "poll_UART" function should poll the status register of the UART. # If the 2^1 bit position (ready bit) is set to 1 then it # should copy the receive buffer's value into $v0 and send # a clear status command (2^1) to the command register before # returning (return statement is already included) poll_UART: jr $ra nop # The "period_check" function should check if the current character ($v0) # is a period ("."). If it is then it should make a jump to the label, # "paldindrome_check". If the character is not a period then it # should use the included return. period_check: jr $ra nop # The "space_check" function should check if the current character ($v0) # is a space (" "). If it is then it should jump to "main" so # that it skips saving the space character. If not it should # use the included return. space_check: jr $ra nop # The "case_check" function should check if the current character ($v0) # is a lowercase character (i.e. greater than the ASCII value of 'Z'). # If it is then it should convert the value of $v0 to the uppercase # equivalent before returning. If it is already uppercase then it # should skip converting and return. case_check: jr $ra nop # The "array_push" function should save the current character ($v0) to # the end of the array using the tail pointer, $s2, then update the tail # pointer to point to the next element in the array before returning. array_push: jr $ra nop # The "palindrome_check" subroutine should should be jumped to by the period # check function if a period is encountered. This subroutine should contain # a loop that traverses the array from the front towards the back (using the # head pointer, $s1) and from the back towards the front(using the tail # pointer, $s2). If the string is a palindrome then as the array is traversed # the characters pointed to should be equal. If the characters are not equal # then the string is not a palindrome and the print function should be used # to print "No". If the pointers cross (i.e. the head pointer's address is # greater than or equal to the tail pointer's address) and the compared # characters are equal then the string is a palindrome and "Yes" should be # printed. Remember to restore the head and tail pointers to the first element # of the array before the subroutine jumps back to main to begin processing the # next string. palindrome_check: j main nop
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Please view expla...


Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags