Programming Homework Help
Programming Homework Help. UART Palindrome
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