Question: CSE 230 Project 3: UART Calculator Learning Objectives: ? Create modular code and interface with unfamiliar modularized code The Task In this project, you will
CSE 230 Project 3: UART Calculator Learning Objectives:
? Create modular code and interface with unfamiliar modularized code
The Task
In this project, you will be writing a program that parses a mathematical expression containing two signed integers and an operator, then display the resulting value of the expression. You program will receive ASCII strings from the UART, one character at a time (from left to right). It should convert each number, represented as a character string, into a signed integer value, then compute and pass the result to the provided print function. Strings will be terminated using an equals sign (=) character. Negative numbers are indicated using a minus sign (-) character before the number. Your program should be able to handle multiple expression strings concatenated together and treat each string ending with a = as a separate input.
Your program should be able to detect 3 types of invalid inputs: invalid characters, invalid expressions, and input overflow. These error types are detailed below. If any of the errors are detected then the rest of the string (i.e. all characters leading up to and including the next =) should be received by the UART, but ignored. Your program should then use the print function to output the appropriate error message (more details on how to do this are given in the print function description) and then continue processing any remaining strings as new strings.
Invalid Characters
When processing strings, it should detect any invalid characters within a string. Invalid characters are any characters other than 0 through 9, =, and the valid mathematical operators: +, -, and * (this calculator does not need to handle division). Space characters ( ) can either be considered invalid or they can be ignored.
Invalid Expressions
An expression is invalid if it contains more than one operator character. For example, 45 ++ 63= would be invalid because it contains two + characters. Something to keep in mind is that the - character is context sensitive because it can be used as both a minus sign and a negative sign. For example, -7- -9= would be valid and should be interpreted as negative seven minus negative nine.
Input Overflow
If a number being input is larger than can be represented by a single 32-bit register then the program should generate an input overflow error. Your program should not generate this error if the result of the expression overflows. You should allow result overflow to occur for this project.
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, the print function will send the value currently in register $a0 over the UART to the PLPTool simulated UART device. Register $a1 is used as an invalid character flag for the print function. If $a1 register contains a non-zero value, the print function will display the corresponding error message indicated in the table below rather than printing the value in register $a0.
| $a0 | $a1 | UART Output |
| Signed Number | 0 | Signed Decimal Number |
| Any Value | 1 | Error: Invalid character |
| Any Value | 2 | Error: Invalid expression |
| Any Value | 3 | Error: Input overflow |
| Any Value | ?4 | Unrecognized error value in $a1 |
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). This initialization only needs to be done once at the start of the program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
