Mars Mips Assembly program

Closed

Description

Ask the user to input a string of expression in RPN form (+ - * / ), use a stack to evaluate the

result and display the result (in decimal) on screen. The numbers and operations in the RPN

expression are assumed to be separated by (one or more) spaces. Assuming no negative

numbers in the input (but intermediate results might be negative).

Calculate single-digit RPN in valid forms. For example:

3 4 – 2 7 + * 4 / = -2 is a valid RPN

Allowing multi-digit numbers, and detecting illegal RPN

expressions. For example:

3 100 105 - + 433 * = -866 is a valid RPN

3 100 105 - + * 433 is invalid

3 abc 105 - + 433 * is invalid

Extra Goal a) (20 pts): achieving the above levels for both RPN and PN. For example:

3 100 105 - + 433 * = -866 is a valid RPN

- 120 / * 3 12 - 42 36 = 114 is a valid PN

- 120 3 100 105 - + 433 * is invalid

b) (20 pts): support of real numbers:

0.3 [url removed, login to view] [url removed, login to view] - + 3 * = [url removed, login to view] is a valid RPN

:

First, you need to prepare a stack structure that supports push / pop, etc.

a) From left to right, go through every character of the expression, do the following:

i. if the character is a digit (0 – 9):

convert the ASCII to integer and push that number onto stack

ii. if the character is an operation (+ - * / )

1. pop from the stack a number -> A

2. pop from the stack a number -> B

3. calculate B op A ( for /, use quotient as result and ignore remainder).

4. push the result number back onto stack

b) Pop out from stack -> final result

Skills: Assembly

See more: mars assembly input, real expressions, pn 1 form, integer real number, integer and real number, mips ASSEMBLY, mips assembly program, ask user number assembly mips, convert ascii, ascii convert, mips mars, mars program assembly language, program remainder, assembly code program written mips, mips assembly example program, result number, program final, rpn assembly, convert ascii decimal, string expression, mips assembly ascii, example convert assembly, ascii integer mips, mips program, convert number ascii mips

Project ID: #5191080

Awarded to:

greenvector

Thanks for considering me again. Just let me know in how many days you want this to be done?? Looking forward to your reply...

$30 USD in 4 days
(12 Reviews)
3.3