[z-machine] Returning 2 from @save in z5
David Carlton
carlton@bactrian.org
Mon, 29 Sep 2003 22:11:48 -0700
On Mon, 29 Sep 2003 20:01:57 +0100, Thomas Thurman <thomas@thurman.org.uk> said:
> My question is: how can a terp ever validly store a 2, "this is a
> restore", from @save? Suppose we load an arbitrary game from
> disk. The PC is pointing at the instruction after the @save which
> saved the game. We don't know where that @save was storing to, so we
> can't write the 2 out anywhere.
I was confused about this for a while, too. But the answer, as far as
I can tell, is that the return PC is supposed to be the address of the
byte of the save instruction telling you where to store the value at,
_not_ the instruction after the save. This, at least, seems to be the
way that XZip does things. If I'm reading the code of my interpreter
correctly, at least: I remember grappling with this issue, that seems
to be what the interpreter does, and I just verified by running it
against Trinity that my understanding seems to agree with XZip's
understanding.
Certainly the Quetzal standard could stand to be clarified on this
matter.
David Carlton
carlton@bactrian.org