zd is, I’m somewhat embarrassed to say, roughly thrown together and not particularly well tested. To be honest, I didn’t really ever think anybody would even try using it!
I think I’d consider a “variable 2OP” with the wrong number of operands more undefined behavior than an ill-formed instruction. It can be decoded with no problem, even if it’s generally nonsensical. Maybe it’d be nice to have a little note/warning that it’s invalid, though.
For what it’s worth, interpreters seem to (almost) universally accept instructions like this. If you have the
za assembler, you can build this:
add 10 20 -> sp
byte 0xd4 0xff 0x00
print "Result: "
read_char 1 -> sp
The byte string there is a variable 2OP “add” instruction with all operands omitted. I’m attaching a build here: 2op.zip (254 Bytes)
add 10 20 -> sp as the first thing. Then we have the equivalent of, basically,
add -> sp.
Almost all interpreters I tried ran this without failing.
Several interpreters printed out
30 (Bocfel, Fizmo, Frotz, Windows Frotz, XZip, Nitfol), presumably because they reuse an operand list which contains values from the previous instruction.
A couple printed out
0 (Zoom and ZVM/Lectrote), meaning they presumably zero out the operand list each time.
Viola failed with an
IndexError, trying to index into an empty list. Presumably it creates an empty list for each new instruction encountered.
I don’t know if there’s much to do with this information, but it was interesting to look at.