MIPS Project 4: Postfix Expression Calculator in Hex Assigned On: Apr 5 th , 2017 Due On: April 26 th , 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 f
UOPOnlineTutorMIPSProject4:
PostfixExpressionCalculatorinHex
AssignedOn:Apr5 th ,2017
DueOn:April26 th ,endoftheday(11:59pm)
--NOLATEDELIVERYACCEPTEDTHISTIME--
WehavediscussedinclassthedetailsofINFIXandbrieflyPOSTFIX.InthisfinalProject,youneedtoimplementa
postfixexpressioncalculator,wherenumbersareinhex,andwitha >>STACK<< ofyourown(ofsize5).With
yourownstack,youareresponsibleofdesigning(coding)theregularstackoperations(suchaspush/pop),aswell
ascheckforoverflow/underflowatappropriateplaces.
Yourprogramwilltaketheuser’sinputasapostfixexpressionwithhexnumbers,useyourownstacktoevaluate
it, and display the result in both hex and decimal forms. The numbers and operations in the expression are
assumedtobeseparatedby(oneormore)spaces.Youcanassumethatnonegativenumberswillbepresentedin
theinputexpression,butintermediateandfinalresultsmightbenegative.
Youhavethreedifferentlevelsofcompletion:picktheONEwithwhichyouaremostconfident:
SilverLevel[80/100POINTS]
Calculateasingle-digitvalidpostfixexpression.Forexample:
9 A – 4 8 + * B / = -1 (dec), -1 (hex)
E 0 A B + 7 / - - = 17 (dec), 11 (hex)
GoldLevel[100/100POINTS]
Samephilosophyofthepreviouslevel,butnowallowingmulti-digitnumbers,detectingillegalpostfixexpressions,
aswellasreportingoverflowforyourstack.Forexample:
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
PlatinumLevel[120/100POINTS]
WiththerespecttotheGoldLevel,yourprogrammustsupportrealnumbersininput,suchas10F.DE3.Output
onlyneedstobeindecimalthistime.
ExamplealgorithmofpostfixcalculationforsingledigitnumbersinHex:
a)
Fromlefttoright,gothrougheverycharacteroftheexpression,dothefollowing:
i. ifthecharacterisavaliddigitinHex(0–9,A-F):
converttheASCIIbytetointegerandpushthatnumberontostack
ii. ifthecharacterisanoperation(+-*/):
1. popfromthestackanumber->x
2. popfromthestackanumber->y
3. calculateyopx(for/,usequotientasresultandignoretheremainder).
4. pushtheresultnumberbackontostack
b) Popoutfromstack->finalresult
PAGE 1 of 2
Whattosubmit
Ina*.ZIParchive(mandatory),containing:
1. Yourassemblycodeas*.asmfile;
2. APDFfilecontainingaDETAILEDreportofyourworkdiscussingthephilosophyyoufollowedinsolvingthe
problem,youralgorithmicimplementation+FIVEmeaningfulscreenshotsoftheI/Ooutputwindowfrom
MARS(eventuallyaddafewcommentstodescribethem).
Wheretosubmit
TurninyourworkonBlackboardasAssignment,withintheProgrammingProjectssectionintheCourseMaterial,as
a*.zipfile,containingcodesourcefileinassemblyandreportinPDF.
Gradingcriteriaforthislab
•
•
•
Programfunctionalityandcorrectness(40%);
Labreport(50%)judgedbythewrite-upqualityandinsightfulness;
Codequalityandstyle(10%).
- 7 years ago
Purchase the answer to view it
- sol_2.zip