Home | Contents | KwikPik |
If you reckon you know all there is to know
about Z80 machine code, prepare for a shock.
As well as the documented instructions, there
are over a hundred that have been hidden
away. David Jones uncovers them and adds the
missing info. Now you really can have your chip
with everything! H I D D E N E X T R A S ![]() | ![]() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Inside every Spectrum lives a
chip - the Z80 created by
Zilog - and with it there are
nearly seven hundred well-
documented instructions for
the machine code programmer
to play about with. Much
more interesting though, are
the instructions that Zilog left
in the Z80 but never bothered
to document. Why? Because
they couldn't be guaranteed to
work in every chip. In all,
there are 102 of them and
you'll find that they're being
used more and more in many
commercial games. You may
even have hacked into one
such program and just not
been able to make any sense
of it. There are two reasons for this increasing popularity with professional programmers. Firstly, these instructions are a very neat way of fooling the hacker. As the only assembler on the market that can cope with any of these instructions is Picturesque's, hackers can have a rough time of it trying to decipher what's going on if they're only armed with a standard assembler. Secondly and even more important, is that these instructions perform operations that can't be carried out anywhere near as easily using the standard instruction set. There has to be a catch, you're saying. And yes, there is - sort of. As Zilog hasn't provided any official info, a |
new version of the Z80 minus
some or all these extra
commands can come out at
any time. It may even be
inside your Speccy! BUG BYTESThe first ten of these hidden instructions are the result of a Z80 'bug'. In the original specifications for the Z80, Zilog included SLA (Shift Left Arithmetic), SLL (Shift Left Logical) SRA (Shift Right Arithmetic) and SRL (Shift Right Logical). Unfortunately, the SLL instruction didn't work, so rather than re-design the Z80 or admit that there was a non-working instruction, Zilog simply pretended that it just didn't exist. Sneaky, eh? The way that SLL fails to work is pretty simple but it can be put to some use in certain circumstances. It should shift a byte left and set bit zero to 0. In reality, it shifts the byte left and then sets bit zero to 1.In all there are ten SLL instructions since it can operate on data supplied by various methods. It's doubtful that you'll find any earth- shattering uses for these instructions as the Z80's already supplied with a pretty comprehensive set of 8-bit shifts and rotates. Still, you can now include these 'bug' instructions in the SLS (Shift Left Set) mnemonic. If you're into scribbling in the margins of your technical |
manuals, turn to page 136 of
the Spectrum Basic Programming Manual. You
can now fill in the space from
code 48 with the new
mnemonic SLS eight times,
followed by the appropriate
registers in the same order as
they appear for SLA, SRA
and SRL. That takes care of
eight out of the first ten. The
remaining two are the same
instructions using data
supplied by the index registers.
Now, using our new
mnemonics, they are
SLS(IX+0) and SLS(IY+0). Speccy speed-freaks are going to find the next chunk of 92 instructions very useful for adding that extra zip to their machine code. If you take a look at the layout of the Z80's internal structure, you'll see that the IX and IY registers are split into four 8-bit registers instead of the normal two 16-bit registers. This split is the basis for the remaining instructions. Now, the Z80 was designed in such a way that it includes all of the instructions available on the 8080 processor plus its own additional instructions and extra registers. So, amongst the extra features are bit-handling, use of the IX and IY registers and a whole series of 'special' functions, including LDIR. To make use of these new features, the processor has some one-byte 'flag instructions' that perform the following: |
As I said before, I can't guarantee that all these instructions will work with every Spectrum but I've yet to find one that won't. If it turns out to be yours, I want to be the first to know. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
THE EXTRA SET This is your new found Z80 instruction set. The first ten are the SLL Instruction set. |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If you want to use the IY register in your own machine code programs, start the instruction with FD instead of DD. You'll also have to avoid most ROM calls and disable the interrupts with DI or you could have a few problems. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Home | Contents | KwikPik |