Assembler - Z80 Flags: undocumented command processor Z80.

Virtual Worlds #01
           Z80-Flags.



                   (C) Unknown
 (Text taken from the Spectrum
 Conference fido7.zx.spectrum)



  There is another unlit
area in the processor Z80, which has implications for
Some programs, such as
Sabre Wulf, Ghosts'n Goblins and
Speedlock. This undocumented flags!


  Bits 3 and 5 of the flag register
F is not used. But they can
contain information and it can
be used because there are such obvious command, like PUSH AF 
and POP AF. But however, sometimes still

contents of these flags are changed. I found the following rule 
of thumb: 


  The values ​​of bits 7,5,3 repeat
values ​​of the corresponding bits
last 8-bit result
instructions, which I usually flags.


  For example, after the team ADD
A, B, these bits will be identical bits in register A. Bit 7 
Register F - is the sign bit, and he, of course, by definition, 
always should be the rule. exception is the team CP x (where

x - register or (HL) or direct
argument). In that case bits
not copied to the result, but with
argument.


  For instructions that operate on double-byte operands
8 bits within the derived rule - it's top 8
bits from 16-bit result.
This should be expected, since there is a significant
Senior 15th bit.


  Ghosts'n Goblins use
undocumented flags as a result of programmer error. In
Playing Sabre Wulf unnatural acts rhinoceros
which sometimes runs low
circles in the corners, if the sign
Bit by BIT team calculated
wrong. I quote:

# AD86 DD CB 06 7E BIT 7, (IX +6)
# AD8A F2 8F AD JP P, # AD8F


  Striking piece of code! A
As for "Spidloka", then
He maketh a number of
obscure and puzzling tricks that in order for it to work in the 
emulator, it should tochnehonko correspond to the real Spectrum.