Mistake of flag and operation in emulation of Z80 and R800


Supporter (9)

GORIPON's picture

16-01-2005, 19:01

I found the following mistakes by the Z80 emulation.

1.The Cy flag is not changed by the INI/INIR/IND/INDR/OUTI/OTIR/OUTD/OTDR instruction.
It changes in real hardware though it is described in the latest user manual(www.zilog.com/docs/z80/um0080.pdf) as "not affected".
Detailed operation has data in www.msxnet.org/
Emulator with problem: The one made based on fMSX.(MSXPLAYer is included.)

I found the following mistakes by the R800 emulation.

2.The behavior of an undefined flag is different from real hardware.
An undefined flag has not been changed though it tried by some instructions in real
DAA instruction seems to do the same operation as Z80 exceptionally.
Emulator with problem: All emulators?(I examined MSXPLAYer and blueMSX.)

3.Some operation is done by an undefined instruction.
Nothing was executed though it tried by some instructions in real hardware.
For example:
DD 18 01 00 00 C9
When this code is called, it becomes BC=0000h in R800.
Anything doesn't change in Z80.
Emulator with problem: All emulators?(I examined MSXPLAYer and blueMSX.)

I'm sorry by poor English.

Login or register to post comments

By pitpan

Prophet (3145)

pitpan's picture

16-01-2005, 19:11

Yes, we all know that the "official" Z80 docs have several mistakes. I do consider Sean Young's Z80 undocumented documented as the most accurate Z80 description. Have you tested openMSX? It is very accurate in all its aspects.

About the R800 processor I cannot neither agree nor disagree because I just use it to switch back to Z80 mode. I am not a Turbo-R guy!

Congratulations for your research. Go on with it!

Edward Robsy

By flyguille

Prophet (3028)

flyguille's picture

16-01-2005, 20:40

Hi, GORIPON... so you did some tests ....

i wonders why, normaly when something is undocumented or not know in the ages of the Z80/R800 just wasn't used by the programmers neighter by its aplications.... well, maybe for some anti-piracy protections.

But anyway, a lot of undoc. details are already documented.... the most useful is the IYh IYl IXh IXl instrucction set.



avoiding in that way the trick of the PUSH IX, POP BC, and in some times is needed because in that way you don't touch the reg C.

Well, there are a lot of hidden thinks, i personaly scan all the ED xx set several times... like in 90's. Smile

but there is a lot of guys that get betters investigations that I did.

i wonders, from where you are?

By dvik

Prophet (2200)

dvik's picture

16-01-2005, 20:50

Thanks for the research. If you have more details I'd be happy to know.

pitpan, If the tests fails in blueMSX it most likely fails in openMSX as well. blueMSX and openMSX passes the zexall testsuite but neither emulator has any R800 specific behavior except from timing and the mul instructions.


Supporter (9)

GORIPON's picture

17-01-2005, 08:57

Thank you for the response.

I know an excellent analytical result of Z80 exists.
However, the MSX emulator that doesn't notice the mistake of the user manual exists.
I hope for this problem to be corrected with all emulators.

When R800 undefined instruction does the same operation as Z80, the possibility that the compatibility problem occurs is very high.
The undefined instruction mentioned here indicates all the codes not being written to the instruction table of R800.
It is not the same as Z80 undefined instruction.
In R800, most of the instruction that doesn't relate to the IX/IY register with the DD/FD prefix is an undefined instruction.
The exception is LD instruction 8bit register.
I want to pass on this information to the author of the emulator.

By snout

Ascended (15184)

snout's picture

17-01-2005, 09:13

It seems you have done quite some thorough investigation, Goripon! Do you know of any software that runs badly on emulators because of this Z80/R800 incompatibility?

Is it possible to write an R800 emulation test, similar to -say- ZEXALL ?


Supporter (9)

GORIPON's picture

17-01-2005, 16:43

The software that doesn't operate about these problems has not been
However, if it is the following problems of newly discovering it, it is
likely not to operate:

In R800, an undefined SLL instruction does the same operation as the SLA
Moreover, doesn't operate the SLL(IX+d) instruction and the SLL(IY+d) instruction.
It operates as an instruction into which only the flag is changed.
This instruction sets the S/Z/H/P/N flag to 1, and copies bit7 of A register onto Cy.

Because the operation of the instruction is different, this seems a more serious problem.
The software that works by Z80 might not work by R800.
Of course, if software that uses the SLL instruction doesn't exist, it is not a problem. :-)
Still, there might be an emulator author who thinks it to be important.
Therefore, I have disclosed this information.

By the way, is ZEXALL an emulator of Z80?
Because English can be read and written only a little, it cannot know details of
On what does ZEXALL insist?

By Sonic_aka_T

Enlighted (4130)

Sonic_aka_T's picture

17-01-2005, 17:06

Zexall is a little Z80 machine code program that can be used to check if an emulator handles instructions in the same way a real Z80 does. If checks if undocumented opcodes work properly and also checks if the flags are set correctly. I think that snout is proposing that someone makes Rexall ^_^


Supporter (9)

GORIPON's picture

17-01-2005, 17:12

>Have you tested openMSX? It is very accurate in all its aspects.
It failed though it tried to use OpenMSX. X-(

Operation of R800 different from Z80 newly found:
In R800, DD DD/DD ED/DD FD/FD DD/FD ED/FD FD operates as NOP in two bytes.
For Example:
DD DD 21 00 00 operates like NOP2+LD HL,0.


Supporter (9)

GORIPON's picture

17-01-2005, 17:18

Thank you for Sonic_aka_T.
It has understood well.