<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 06/13/2010 01:46 AM, Paul Gilbert wrote:
<blockquote
 cite="mid:AANLkTimD_RJGDDcYd5fi_K2s78scF9lX5s6N0Wwfy2YL@mail.gmail.com"
 type="cite">
  <div class="gmail_quote">On Sat, Jun 12, 2010 at 10:47 PM, Michael
Madsen <span dir="ltr"><<a moz-do-not-send="true"
 href="mailto:michael@birdiesoft.dk">michael@birdiesoft.dk</a>></span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
This brings me to my questions:<br>
1) Does your engine have any opcodes that act in a similar way?<br>
2) If yes, do you know if this sort of thing is actually used in any
scripts for your engine?<br>
  </blockquote>
  <div><br>
  </div>
  </div>
Well, the Tinsel engine is probably one such example. It's stack based,
and one of the fundamental opcodes is 'OP_LIBCALL'. This opcode is
basically an interface to a whole bunch of intrinsic support functions.
How many parameters get popped off the stack (as parameters for each
method) depend on which method is called, which is passed as an
immediate parameter along with the opcode.<br>
</blockquote>
<br>
<tt>I am not sure but that sounds easy to handle, since the parameter
is an immediate and not on the stack (which is what the "variable stack
effects" is all about :-), like it is with SCUMM's startScript.<br>
<br>
As I understand SCUMM's (v6 btw.) startScript the first parameter
passed to it is the size of the argument list passed to the script.
This can be any number followed by the same number of parameters on the
stack. Last but not least there are two parameters: script and flags.<br>
<br>
So a possible call might look like this (this is a *made up* example!):<br>
<br>
push 0             ; flags<br>
push 1             ; script<br>
push 4             ; a4 <br>
push 3             ; a3<br>
push 2             ; a2<br>
push 1             ; a1<br>
push 4             ; Number of arguments<br>
startScript<br>
<br>
In this case the opcode would take seven parameters from the stack. Of
course it might also be called like this:<br>
<br>
push 0            ; flags<br>
push 2            ; script<br>
push 0            </tt><tt>; Number of arguments</tt><br>
<tt>startScript<br>
<br>
There only three parameters are taken from the stack. As you can see
the number of arguments taken from the stack depends on a value on the
stack and NOT on the opcode alone.<br>
<br>
As I get your description of OP_LIBCALL the number of stack parameters
taken is only dependent on the sub function called, which on the other
hand is exactly defined in the bytecode representation, i.e. it does
not depend on any values on the stack.<br>
<br>
So as long as every method does have a constant number of arguments all
it would only be required is to properly output different instructions
in the TINSEL dissassembler.<br>
<br>
// Johannes</tt><br>
</body>
</html>