Re: HLL expression -> ASM

"Randall Hyde" <>
31 Mar 2001 02: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)
Re: HLL expression -> ASM (2001-04-10)
| List of all articles for this month |

From: "Randall Hyde" <>
Newsgroups: comp.compilers
Date: 31 Mar 2001 02:48:29 -0500
Organization: Posted via Supernews,
References: 01-03-131 01-03-153
Keywords: code, assembler
Posted-Date: 31 Mar 2001 02:48:29 EST

"Dan Bishop" <> wrote in message
> 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.
> [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]

Note, btw, that Alex failed to mention that the target platform is
the x86 which has limited registers and each register has some
special uses that may or may not be needed for certain calculations
in the expression (e.g., EDX:EAX for DIV/IDIV, CL for SHL/SHR,
etc). Having read his posts in CLAX, I can assure you that using
the hardware stack in place of the registers is unacceptable (except,
of course, for spilling the registers if an expression gets too complex).
Suitable questions are:
(1) is it better to reserve certain registers for specific purposes or
treat them all as general purpose and deal with the exceptions
as they arise?
(2) How to choose which register to use (e.g., I suggested using
a powerset, extracting and returning registers as needed).
(3) How best to handle spilling register to memory.
Randy Hyde

Post a followup to this message

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