iftechfoundation / Z-Machine-Standard

22 stars 4 forks source link

New remark in section 6 #72

Open fredrikr opened 4 years ago

fredrikr commented 4 years ago

We just discovered a bug in several of the original Infocom interpreters for Z80- and 6502-based platforms (Amstrad, Apple II and more), which I think should be mentioned in the specification.

According to 6.4.4.1:

It is legal for there to be more arguments than local variables (any spare arguments are thrown away) or for there to be fewer.

However, many of the Infocom terps apply any extra arguments to the local variables of the current routine.

[Routine1 a b c; Routine2(1, 2, 3); ];

[Routine2 x y; rtrue; ];

The routine call in routine1 sets c to 3, since Routine2 only accepts two arguments.

fredrikr commented 4 years ago

As it turns out, this behaviour is also present in the 16-bit MS-DOS interpreter and the 16-bit Atari ST interpreter.

All of these are z3 interpreters, BTW.

It may be that Infocom's compiler didn't allow for this kind of code to be compiled, so it was never a problem for their games.