[virtmach] bytecodes and stacks

Mark W. Humphries mwh@intranetsys.com
Fri, 30 Nov 1999 13:17:17 +0800

-----Original Message-----
From: Ceri Storey <cez@nomorespam.freeserve.co.uk>
To: Virtual Machine List <virtmach@iecc.com>
Date: Monday, November 29, 1999 5:28 AM
Subject: [virtmach] bytecodes and stacks


> The questions are:
> Is it possible to just push/pop things off one stack, allowing for things
> like global-variables and locally bound ones (eg. let in scheme)? or would
> several be needed, leading to a towers of hanoi like situation, when you
> needed  to reference a variable form an earlier "stack frame", not a fun
> soulution.

I think you'll find a 2 stack virtual machine model offers the best overall
combination of flexibility and simplicity. One stack being used for
function/subroutine parameter values, and one for subroutine return
addresses (and optionally the exception chaining). This is the model
advocated by most Forth programmers. Forth being the language that has
traditionally had the simplest and lowest-level underlying virtual machine

BTW, a good taxonomy for interpreter VM models and instruction sets is found
in the first half of:
Interpretation and Instruction Path Coprocessing
MIT Press - ISBN 0-262-04107-3
Eddy H. Debaere & Jan M. Van Campenhout
Published in 1990, unfortunately out of print but probably findable

 Mark W. Humphries