Newsgroups: comp.sys.sinclair
Path: ulke.hiMolde.no!trane.uninett.no!sunic!sunic.sunet.se!umdac!cs.umu.se!mac-126.cs.umu.se!user
From: lashem95@student.umu.se (Lars Hellstrm)
Subject: Machine code for unofficial instructions
Message-ID: <lashem95-310595130558@mac-126.cs.umu.se>
Followup-To: comp.sys.sinclair
Sender: news@cs.umu.se (News Administrator)
Organization: Dept. of Computing Science, Umea Univ., 901 87 Umea, Sweden
Date: Wed, 31 May 1995 11:12:03 GMT
Lines: 24

I happen to be writing (although no very fast) a Spectrum emulator
for the Macintosh. When going through the instruction set of the Z80
recently (to include some new things I'd came across), I saw one
thing that had escaped my attention for years: The thrid byte of
instructions such as BIT 0,(IX+12) is the offset, not the main
instruction code (which seems to me as a more natural scheme).

After thinking a while I realized why: It reduces the execution time
of the instruction by some four clock cycles, since the calculation of
the final adress can be done simulaneously with the fetch of the main
instruction byte. Neither can it cause any confusion about what shall
be done as long as one is using only official instructions.

However, I have learnt from the FAQ that there are unofficial
instructions such as BIT with the high part of IX and similiar. To
aviod confusion then, I can se no other possibility than that in the
opcode of this, the third byte is discarded by the processor and the real
instruction byte comes in the fourth byte; which should give something
like "DD CB anything 44" to test bit 0. Are these assumptions correct ?

It is only recently that I have found the Spectrum (etcetera) sites
of the Internet, and I haven't had much time to look around. Therefore,
if my questions have an easy answer somewhere, please forgive me
(and drop me a line to tell me where).
