Testing Z80 Emulation...

Emulator and emulator development specific topics
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Testing Z80 Emulation...

Post by PokeMon »

Rink wrote: Is is just the EXX and EX AF,AF' instructions that can do anything with them?
Yes you have just two sets of main registers.
The reason was that the founder of Zilog, Federico Faggin, changed from Intel and wanted to have a (software compatible) CPU of the 8080 but some more functionality, especially more registers. This was a luck of the 8080. To do that he just implemented a double set of the main registers AF, BC, DE, HL and implemented to instructions to simply change (or choose) the register set you are working with. The non active registers remain with there old contents.

So EX AF,AF' just toggle between AF and AF' (in fact there is no existing AF' it is just a naming convention for a so called shadow register or however you would name it).

The same is for BC,DE,HL which are toggled with just the EXX instruction.

All instructions for A,B,C,D,E,H,L,Flag register or BC,DE,HL just refer to the actual active register set.

Here you can see a list of improvements for the Z80 in comparison to the 8080:
http://en.wikipedia.org/wiki/Zilog_Z80


Anyway - be aware to trust this document too much.
http://www.zilog.com/docs/z80/um0080.pdf

I reported several errors to Zilog and they confirmed to change 6 month ago - but nothing changed. :oops:
Has wrong binary codes and lot of copy and paste errors inside. For example listed DD FD as code for POP IY but correct is FD E1. Has many more errors.
It is more readable than the old PDF but anyway many parts and codes not correct.
I would propose to use the attached PDF which is not very readerfriendly but has a correct instruction set.
ps0178.pdf
(1003.21 KiB) Downloaded 337 times
Rink
Posts: 165
Joined: Wed Jun 27, 2012 5:48 pm

Re: Testing Z80 Emulation...

Post by Rink »

Bloody Zilog. That's exactly the document I've been checking against.

The original libz80 author hopefully accounted for that, but I'll have to go through the doc you posted before releasing the c# port.

Cheers fella.
User avatar
RetroTechie
Posts: 379
Joined: Tue Nov 01, 2011 12:16 am
Location: Hengelo, NL
Contact:

Re: Testing Z80 Emulation...

Post by RetroTechie »

Yes, IIRC these alternate registers were also meant to aid in coding fast interrupt routines:

Interrupt -> EX AF,AF' / EXX -> process interrupt -> EX AF,AF' / EXX -> return from interrupt.

Much faster than pushing + popping a whole bunch of registers onto the stack. Of course that is: for systems where main code doesn't use the alternate registers (like an embedded system with 1 simple function). A similar story goes for IX and IY.
User avatar
RetroTechie
Posts: 379
Joined: Tue Nov 01, 2011 12:16 am
Location: Hengelo, NL
Contact:

Re: Testing Z80 Emulation...

Post by RetroTechie »

Z80 CPU User Manual is easy on the eyes but contains a number of errors (which, like PokeMon said, don't seem to get fixed anymore). I consider that document buggy & unmaintained.

Z80 CPU Product Specification looks ugly, but is compact & accurate. And there's the Mostek MK3880 Technical Manual, which is more extensive and at least as accurate. Personally I rarely use the latter (more pages to flip through before you arrive @ what you wanted ;) ), but regard it as the best Z80 documentation around. Add to that a few small / non-official documents that describe undocumented Z80 behavior, and you're all set.

In case that leaves any questions open: original, Zilog-built NMOS Z80 chip is the ultimate reference. :geek:
Post Reply