Re: HLL expression -> ASM

"Dan Bishop" <danb2k@hotmail.com>
27 Mar 2001 23:48:29 -0500

          From comp.compilers

Related articles
HLL expression -> ASM alexfru@chat.ru (Alexei A. Frounze) (2001-03-26)
Re: HLL expression -> ASM danb2k@hotmail.com (Dan Bishop) (2001-03-27)
Re: HLL expression -> ASM dummy_addressee@hotmail.com (Alexei A. Frounze) (2001-03-31)
Re: HLL expression -> ASM titzer@expert.cc.purdue.edu (Ben L. Titzer) (2001-03-31)
Re: HLL expression -> ASM rhyde@transdimension.com (Randall Hyde) (2001-03-31)
Re: HLL expression -> ASM marcov@stack.nl (Marco van de Voort) (2001-04-04)
Re: HLL expression -> ASM dummy_addressee@hotmail.com (Alexei A. Frounze) (2001-04-10)
Re: HLL expression -> ASM bill@megahits.com (Bill A.) (2001-04-10)
[1 later articles]
| List of all articles for this month |
From: "Dan Bishop" <danb2k@hotmail.com>
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" <alexfru@chat.ru> 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.