|Compilers, Aho/Sethi/Ullman, Exercise 2.15 email@example.com (2006-06-05)|
|Re: Compilers, Aho/Sethi/Ullman, Exercise 2.15 firstname.lastname@example.org (Pascal Bourguignon) (2006-06-07)|
|Re: Compilers, Aho/Sethi/Ullman, Exercise 2.15 email@example.com (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 <firstname.lastname@example.org>|
|Date:||7 Jun 2006 23:17:49 -0400|
|Posted-Date:||07 Jun 2006 23:17:49 EDT|
email@example.com wrote in news:firstname.lastname@example.org:
> 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
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.
Return to the
Search the comp.compilers archives again.