Re: HLL expression -> ASM

"Dan Bishop" <>
27 Mar 2001 23:48:29 -0500

          From comp.compilers

Related articles
HLL expression -> ASM (Alexei A. Frounze) (2001-03-26)
Re: HLL expression -> ASM (Dan Bishop) (2001-03-27)
Re: HLL expression -> ASM (Alexei A. Frounze) (2001-03-31)
Re: HLL expression -> ASM (Ben L. Titzer) (2001-03-31)
Re: HLL expression -> ASM (Randall Hyde) (2001-03-31)
Re: HLL expression -> ASM (Marco van de Voort) (2001-04-04)
Re: HLL expression -> ASM (Alexei A. Frounze) (2001-04-10)
Re: HLL expression -> ASM (Bill A.) (2001-04-10)
[1 later articles]
| List of all articles for this month |

From: "Dan Bishop" <>
Newsgroups: comp.compilers
Date: 27 Mar 2001 23:48:29 -0500
Organization: Texas A&M University, College Station, Texas
References: 01-03-131
Keywords: code, comment
Posted-Date: 27 Mar 2001 23:48:29 EST

Here's a simple, but inefficient method:

Do a postorder transversal of the tree. When a value/variable is reached,
emit code to push it on to the CPU stack. For "operator" nodes, pop two
values from the stack, perform the operation, and push the result back onto
the stack.

"Alexei A. Frounze" <> wrote
> I know how to parse the source, how to evaluate expressions several
> similar ways: recursively or using stack(s). OK, that works perfectly,
> no problems. And I can create a tree for the expression as well.
> Now, how do I transform the tree/whatever (let's say only integer
> values/vars involved in the expression) into an ASM piece of code w/o
> consuming extra memory for partial results, just using CPU registers?

[If you pretend the registers are the stack and assign the "pushed"
values to registers, you can get code that's not bad considering how
easy this technique is. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.