Related articles |
---|
Compilers, Aho/Sethi/Ullman, Exercise 2.15 tomazos@gmail.com (2006-06-05) |
Re: Compilers, Aho/Sethi/Ullman, Exercise 2.15 pjb@informatimago.com (Pascal Bourguignon) (2006-06-07) |
Re: Compilers, Aho/Sethi/Ullman, Exercise 2.15 cdodd@acm.org (Chris Dodd) (2006-06-07) |
Re: Compilers, Aho/Sethi/Ullman, Exercise 2.15 DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-06-07) |
From: | Chris Dodd <cdodd@acm.org> |
Newsgroups: | comp.compilers |
Date: | 7 Jun 2006 23:17:49 -0400 |
Organization: | Compilers Central |
References: | 06-06-019 |
Keywords: | books |
Posted-Date: | 07 Jun 2006 23:17:49 EDT |
tomazos@gmail.com wrote in news:06-06-019@comp.compilers:
> The parts labeled with ???? are illegal in the stack machine-code. The
> problem is that I need to store the initial evaluation of STEP and
> LIMIT somewhere, and I don't see how this is possible to do using the
> stack. There is also no mention of a way to create and allocate a new
> variable, or anywhere else I could store them.
Your code looks correct and you've basically figured out the problem -- you
need a way of creating a new temporary data location to hold the STEP and
LIMIT values. So you just need to call a 'newdatalocation' function that is
exactly analogous to the 'newlabel' function you're already calling, and it
will give you a unqiue tag/address that you can use with the lvalue/rvalue
instructions.
Alternately, you could introduce new instructions to manipulate the stack,
which would have the advantage that it would be reentrant -- using a global
temp to hold the STEP and LIMIT values will fail if the loop contains a
recursive call to the function containing the loop.
Chris Dodd
cdodd@acm.org
Return to the
comp.compilers page.
Search the
comp.compilers archives again.