UART Palindrome Checker using PLP Software tool 5.2 (MIPS) Create modular code a
ID: 3750697 • Letter: U
Question
UART Palindrome Checker using PLP Software tool 5.2 (MIPS)
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 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 $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).
Explanation / Answer
DATA SEGMENT STR1 DB "ENTER YOUR STRING HERE: ->$" STR2 DB "STRING ENTERED ->$" STR3 DB "REVERSED STRING ->$" INSTR1 DB 20 DUP("$") RSTR DB 20 DUP("$") NEWLINE DB 10,13,"$" N DB ? S DB ? MSG1 DB "YES $" MSG2 DB "NO $" A DB "1" DATA ENDS CODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX LEA SI,INSTR1 ;GET STRING MOV AH,09H LEA DX,STR1 INT 21H MOV AH,0AH MOV DX,SI INT 21H MOV AH,09H LEA DX,NEWLINE INT 21H ;PRINT THE STRING MOV AH,09H LEA DX,STR2 INT 21H MOV AH,09H LEA DX,INSTR1+2 INT 21H MOV AH,09H LEA DX,NEWLINE INT 21H ;PRINT THE REVERSE OF THE STRING MOV AH,09H LEA DX,STR3 INT 21H MOV CL,INSTR1+1 ADD CL,1 ADD SI,2 L1: INC SI CMP BYTE PTR[SI],"$" JNE L1 DEC SI LEA DI,RSTR L2:MOV AL,BYTE PTR[SI] MOV BYTE PTR[DI],AL DEC SI INC DI LOOP L2 MOV AH,09H LEA DX,NEWLINE INT 21H MOV AH,09H LEA DX,RSTR INT 21H MOV AH,09H LEA DX,NEWLINE INT 21H ;PRINT THE STRING IS PALINDROME OR NOT LEA SI,INSTR1 LEA DI,RSTR MOV AH,09H LEA DX,NEWLINE INT 21H ADD SI,2 L7: MOV BL,BYTE PTR[DI] CMP BYTE PTR[SI],BL JNE LL2 INC SI INC DI MOV BL,BYTE PTR[DI] MOV AH,02H MOV DL,BL INT 21H MOV AH,09H LEA DX,NEWLINE INT 21H CMP BYTE PTR[DI],"$" JNE L7 MOV AH,09H LEA DX,NEWLINE INT 21H MOV AH,09H LEA DX,MSG1 INT 21H JMP L5 LL2: MOV AH,09H LEA DX,NEWLINE INT 21H MOV AH,09H LEA DX,MSG2 INT 21H L5: MOV AH,4CH INT 21H CODE ENDS END START
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.