Re: Stack Machine and Parameters

"amal" <>
16 Dec 2004 00:48:37 -0500

          From comp.compilers

Related articles
Stack Machine and Parameters (Jens Kallup) (2004-11-29)
Re: Stack Machine and Parameters (amal) (2004-12-16)
| List of all articles for this month |

From: "amal" <>
Newsgroups: comp.compilers
Date: 16 Dec 2004 00:48:37 -0500
References: 04-11-129
Keywords: code, architecture
Posted-Date: 16 Dec 2004 00:48:37 EST

Jens Kallup wrote:
> Hello Newsgroup,
> I trying to program an interpreter in stack machine behavior.
> It works fine at now - IF ELSE ENDIF FOR loops and
> variable definitions like "b0 = 100".
> But now, I reached the point where parameters of functions
> should be interpreted. I don't know how it possible.
> I pushed parameters on stack of functions that are fixed and
> know by me - but how works with unknow procedure
> parameters?
> Here a little code snippet of the parsed interpreter code:
> enter main
> npush 10
> vpush b0
> add
> nassign b0
> call @test
> ret

evaluate the arguments. push them to the stack ( assuming call by
value) . on function invocation pop as many arguments as the arity of
the function. do the functions job.


CALL MAX ( 1, A+B+C, SQUARE( A - B)) can be translated as
lets assume we evaluate from left to right.

vpush A
vpush B
call @sq
vpush A
vpush B
vpush C
npush 1
call @max


Post a followup to this message

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