PDA

View Full Version : algebraic solver



JSoftware
15-07-2005, 09:23 AM
i'm making a small pascal to pic compiler and i've got much of it working but now i'm stuck on the solver. i've tried so much at trying to make on that just work for simple equations but it just won't work! i need to turn a line like this:

bitmask := 2 * (position + RCX_bit);

into:

move position to w
add RCX_bit to w
multiply w with 2
move w to bitmask

just a list of the operations done in the right order..

maybe this wasn't the best example to give but please ask questions if i wasn't clear enough

Many Regards
Jeppe

WILL
15-07-2005, 09:38 AM
You're trying to convert the one line of Pascal code into PIC ASM using the BEDMAS mathmatical ordering scheme with your parser, correct?

Hmm... before getting into this I'd first recommend you read the very informative article Let's Build a Compiler (http://compilers.iecc.com/crenshaw/) by Jack Crenshaw. (Listed in the site's Library!) The source and examples are in PASCAL both supported by Turbo Pascal, Free Pascal and Delphi(with very little modification).