Coder's Guild Mailing List

Re: TCG digest 94

Posted by John Stokes on 1998-03-23

Hello coders alike,
   I am currently writing a calculator in assembly language using Masm 5.1


The calculator should get a string from the keyboard and it allows operators

   + - * and /. It also must allow the use of brackets. I am getting stuck with
how to evaulate the formulae.

  The format of the formulae could be something like this:

  (10+2)+4-3 / 2 + (3+(2-6)) = ?

DOES ANYBODY KNOW HOW I MIGHT BE ABLE TO PARSE THIS STRING.

If there is some source code available in either Pascal OR Assembler I would be
mighty grateful. It would even suffice if someone could point me in the right
direction.

If it helps, what I kind of had in mind was to push the individual components
on the stack, I.e

(10+2)*4 would look something like this sp ->4  
            *
                                              )
                                              2
                                              +
                                              10
                                         bp ->(

and then evaulate by manipulating the stack ???????????

THANX!   Your Coder Companion, Mr E. (commonly known as Common John.)