ECE 267 – Computer Organization I Spring 2017 Paolo Vinella, ECE Dept. at UIC [email protected] MIPS Project 4: Postfix Expression Calculator in Hex Assigned On: Apr 5th, 2017 Due On: April 26th, end of the day (11:59pm) --NO LATE DELIVERY ACCEPTED THIS TIM
ECE 267 – Computer Organization I
Spring 2017
Paolo Vinella, ECE Dept. at UIC
[email protected] MIPS Project 4: Postfix Expression Calculator in Hex Assigned On: Apr 5th, 2017 Due On: April 26th, end of the day (11:59pm) --NO LATE DELIVERY ACCEPTED THIS TIME-- We have discussed in class the details of INFIX and briefly POSTFIX. In this final Project, you need to implement a postfix expression calculator, where numbers are in hex, and with a >>STACK<< of your own (of size 5). With your own stack, you are responsible of designing (coding) the regular stack operations (such as push / pop), as well as check for overflow / underflow at appropriate places. Your program will take the user’s input as a postfix expression with hex numbers, use your own stack to evaluate it, and display the result in both hex and decimal forms. The numbers and operations in the expression are assumed to be separated by (one or more) spaces. You can assume that no negative numbers will be presented in the input expression, but intermediate and final results might be negative. You have three different levels of completion: pick the ONE with which you are most confident: Silver Level [80/100 POINTS] Calculate a single-digit valid postfix expression. For example: 9 A – 4 8 + * B / = -1 (dec), -1 (hex)
E 0 A B + 7 / - - = 17 (dec), 11 (hex) Gold Level [100/100 POINTS] Same philosophy of the previous level, but now allowing multi-digit numbers, detecting illegal postfix expressions, as well as reporting overflow for your stack. For example:
3 64 69 - + 1B1 * = -866 (dec), -362 (hex)
F 10E0 10 - + * 4A33 is invalid
F GH 5 - + 4A33 * is invalid
3 F E0 150 52 4EE * - + * overflows my stack of 5 Platinum Level [120/100 POINTS] With the respect to the Gold Level, your program must support real numbers in input, such as 10F.DE3. Output only needs to be in decimal this time. Example algorithm of postfix calculation for single digit numbers in Hex: a) From left to right, go through every character of the expression, do the following: i. if the character is a valid digit in Hex (0 – 9, A-F ): convert the ASCII byte to integer and push that number onto stack ii. if the character is an operation (+ - * / ): 1. pop from the stack a number -> x 2. pop from the stack a number -> y 3. calculate y op x ( for /, use quotient as result and ignore the remainder). 4. push the result number back onto stack b) Pop out from stack -> final result PAGE 1 of 2 What to submit In a *.ZIP archive (mandatory), containing: 1. Your assembly code as *.asm file; 2. A PDF file containing a DETAILED report of your work discussing the philosophy you followed in solving the problem, your algorithmic implementation + FIVE meaningful screenshots of the I/O output window from MARS (eventually add a few comments to describe them). Where to submit Turn in your work on Blackboard as Assignment, within the Programming Projects section in the Course Material, as a *.zip file, containing code source file in assembly and report in PDF. Grading criteria for this lab •
•
• Program functionality and correctness (40%); Lab report (50%) judged by the write-up quality and insightfulness; Code quality and style (10%). PAGE 2 of 2
9 years ago
Purchase the answer to view it

- run_1.png
- sol_2.zip