Well, I am working on my second assembly program.
I am trying to parse the input 1/4+7/32
The goal is to accept an input as fractions, and perform the math operation between the fractions.
After some searching I believe the easiest way would be to modify the buffer termination to a /, get the numerator, then modify the buffer termination to a ( +, \ , -, * ), get the denominator...etc?
You might want to google "RPN".
Is this is a console application ?
Are you just trying to write the simplest working example ?
If it was me, I'd write several routines,...as a sort of trial and error approach,...just to learn the best technique.
Do you want to validate the entry ? By that I mean, test the entry string to see if it has the proper format and the appropriate characters ?
My first routine would simply scan the input string, testing for length of the input string, the presence of the essential operation characters (+,=,/), and then testing to make sure all the other characters are numbers or line terminators.
Assembly programming is actually kind of fun,...you can write all kinds of simple routines to check values and identify errors.
I'm thinking that the actual mathmatical operations would be fairly straighforward and trivial.
Quote from: jinckz on March 06, 2012, 08:28:49 PM
I am trying to parse the input 1/4+7/32
The goal is to accept an input as fractions, and perform the math operation between the fractions.
Seems pretty straight forward, in that the
/ symbol will no longer represent a division operation.
You just choose another symbol to represent division.
Have you read up on math parsers ?
Have you chosen a parser design you want to implement ?
If not, look up "recursive descent parsers".
if you use the standard "order of operations" as a guide, it will be easier
http://www.mathgoodies.com/lessons/vol7/order_operations.html