Click to See Complete Forum and Search --> : RPN calculator for MIPS :/ - newbie
z-big
June 7th, 2008, 12:33 PM
Hi!
I have to write a reverse polish notation calculator in mips assembler, and i don't have idea even how to start :/ Please give me some hints how to start :/ I've just started to learn MIPS assembler and i know only basics :/
TheCPUWizard
June 7th, 2008, 12:39 PM
Then start with the basics...
Write a program that will add two numbers....Debug it...
z-big
June 7th, 2008, 02:13 PM
i know how to add two numbers ;] RPN calculator is a little bit more complicated ;]
TheCPUWizard
June 7th, 2008, 02:56 PM
Actually, it is just 2 more instructions to push and pop the arguments off the stack.
2 {enter} 4 {plus} 4 { times } = 24
push 2
push 4
add top two values on stack push result
push 4
multiply top two values on stack and push result
pop and display result.
z-big
June 7th, 2008, 07:26 PM
i know how does it work, i'm rather concerned about how can i read the input data... for example if i read from keyboard how can i check what i've read - number or + ?
TheCPUWizard
June 7th, 2008, 07:34 PM
Well, technically that is not part of the "calculator"....
But if you wanted to consider it as such, then simply refer back to my initial post...
Based on your last comment you do NOT know how to meet the requirements but instead of a full function calculator, simply perform addition.
So I will repeat my previous suggestion.... Simply the problem so that you have a "framework" for implementing the calculation.
As far as digits and "-" are concerned.
On a Digit, you simply multiple the "Accumulator" * 10 and add the new Digit, and SET A FLAG.
On ANY operation you push the accumulator on top of the stack IF THE FLAG WAS SET ABOVE, Clear the flag, and perform the uniary, binarary, or even tertiary command on the top elements of the stack.
z-big
June 8th, 2008, 12:24 PM
it has to add, multiply, etc... it seems that spim doesn't recognise push/pop commands :/
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.