News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Commnad Line Calculator using MASM

Started by Jim, May 13, 2005, 02:08:39 PM

Previous topic - Next topic

Jim

I got a homework of a command line calculator, with the ability to handle +,-,*,/, () and big integers (20 digits).
For example, when input (5+2) / 2, it ouputs 3 (or 4).

But I'm just totally new with assembly language and really don't know what to do.

I'm not sure if it's polite to ask for its source code here, but if anyone could offer some help, I really appreciate it.

Mark Jones

Hi Jim, welcome to the group. We'd be glad to give you some pointers, but we will not give source code for anyone's homework. Do you have any previous assembler or HLL experience? What exactly do you need help with - just the command parsing or the entire application? Please post what code you do have so we can help you better. :)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

AeroASM

If you are totally new, why are you receiving homework that is quite difficult? You must have done some before. If you have no idea as to where to start, then we can help you, but no one will do it for you.

If however you have a go but fail, then we would be very glad to help you.

Jim

Well this is my third homework. The previous two are Fibonacci series and Pascal Triangle, and those are my only exp. in assembly.
And I really don't know how come this one is so hard.

I think I need to convert the infix to postfix notation first (using stack?) But I don't know how to use stack in assembly :(

(I was actually hoping if someone got a working example...lol)

Mirno

If we give you a working example, then you'll come back for your fourth and fifth homework assignments asking for "working examples" of those too.

Show us what you've come up with so far, and we'll see what we can do. Although usually this kind of thing is MS-DOS based assembly rather than Win32asm people should still be able to help.

Mirno

AeroASM

The stack is a temporary memory area that is very fast to use.

The top of the stack is referenced by ss:sp. It is called the "top", but it is really the bottom because the stack grows downwards in memory. Example:

Start with sp=100.
Then mov ax,3
push ax
Now sp=98, and [sp]=3
mov ax,5
push ax
Now sp=96, [sp]=5 and [sp+2]=3

|5|3|

Now if we pop cx then pop dx, then cx = 5 and dx= 3
Whereas if you pop dx then pop cx, cx =3 and dx=5

Got it?

pbrennick

Jim,
Welcome to the forum.  Have you read the topic referring to homework?  We need you to show us what code you have begun to develop in reference to this assignment.  If there is a portion of it that is not working, we will help you but you must make the effort first.

Paul

sluggy

I know a few people have said this already, but i'm gonna add my two bits worth.

Quote from: Jim on May 13, 2005, 02:41:57 PM(I was actually hoping if someone got a working example...lol)
Hmmmm.... it took me approx 5 seconds to open a new browser window, and type in the three words required for my Google search, then it took ggogle 0.33 seconds to execute the search, and in the first 10 results were 4 different "calculator in asm" examples. If you want "working examples" then why didn't you do a search? I think it is because deep down you know that you will have the answer (the complete source), but you still won't have the knowledge of how to get that answer (how the source works). Either that or your google skills suck  :bg

Quote from: Jim on May 13, 2005, 02:41:57 PMAnd I really don't know how come this one is so hard.......I think I need to convert the infix to postfix notation first (using stack?) But I don't know how to use stack in assembly :(
Here is one of the most important things you must do when in the Information Systems / IT world: you must understand the specifications, understand what needs to be done. If you are not sure, then swallow your pride and go back and ask your tutor some questions. We can give you all the answers here, but that still doesn't educate you.

How is your calculator supposed to receive its input? Is it on the command line, is it purely text based input (ie in a console window), or is a simple gui required? Once you have your numbers, convert the ASCII to decimal, do the required math, then convert decimal to ASCII and output the answer. If you have the MASM32 package, read the documentation that comes with it, it has some things you can use.