Testing Z80 Emulation...

Emulator and emulator development specific topics
Rink
Posts: 165
Joined: Wed Jun 27, 2012 5:48 pm

Testing Z80 Emulation...

Post by Rink »

Hi,

Just wondering if anyone has a program (asm or bin) that executes every instruction in the Z80 instruction set? I've just finished a C# port of libz80 and am trying to find a lazy way of testing it. :D

It all seems to work, but there's always a chance that some of those instructions that I don't know how to use haven't been implemented properly.
User avatar
Paul
Posts: 1511
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Testing Z80 Emulation...

Post by Paul »

If you download tasm there is a testfile with every mnemonic included and you can compare the outputs to tasm.
In theory, there is no difference between theory and practice. But, in practice, there is.
Rink
Posts: 165
Joined: Wed Jun 27, 2012 5:48 pm

Re: Testing Z80 Emulation...

Post by Rink »

Cool. I'll check that out - cheers mate.
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Testing Z80 Emulation...

Post by PokeMon »

Hi,

I did implement the whole Z80 instruction set (excluding non-official instruction set, working but non-documented instructions by ZILOG) in the ZX81-IDE.
viewtopic.php?f=6&t=795

There you will find a file Z80test.asm which is a summary of all possible instructions and could compare output Z80test.p

By the way - I am not sure if these files are provided with the IDE, will attach it here to be sure.
You maybe have to adjust some labels for testing jumps.
;)

And for the IDE there can be used either () or [] for memory referencing.
In case you have to replace [] with () depending on your assembler engine.
Attachments
Z80test.p
(1.16 KiB) Downloaded 508 times
Z80test.asm
(8.25 KiB) Downloaded 592 times
Rink
Posts: 165
Joined: Wed Jun 27, 2012 5:48 pm

Re: Testing Z80 Emulation...

Post by Rink »

Great stuff Poke, thanks mate.

Didn't get too far with the TASM files - long story - but have fixed one issue with some of the extended opcodes (I forgot to actually code that bit properly) and have tested all the 8-bit load operations successfully.
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: Testing Z80 Emulation...

Post by Andy Rea »

There is also Zexall, you might have to tweak it for ZX81 operation, google it or check out world of spectrum
what's that Smell.... smells like fresh flux and solder fumes...
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Testing Z80 Emulation...

Post by PokeMon »

Rink wrote:Great stuff Poke, thanks mate.

Didn't get too far with the TASM files - long story - but have fixed one issue with some of the extended opcodes (I forgot to actually code that bit properly) and have tested all the 8-bit load operations successfully.
Could also try to assemble the zx81 rom, added as source and binary to the IDE above. ;)
Rink
Posts: 165
Joined: Wed Jun 27, 2012 5:48 pm

Re: Testing Z80 Emulation...

Post by Rink »

Might try that in a bit, cheers. Although I'm just doing the cpu emulation so it might be difficult to test the ROM without any other parts of the ZX system.

I have a question about the alternate registers which hopefully someone can help with. Looking at the Z80 datasheet from Zilog, I can't really see how these things are used.

Is is just the EXX and EX AF,AF' instructions that can do anything with them?
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 and no.

No, because there's no instructions that do anything directly with an alternate register. Not even the exchange instructions: they change what set you're using but not contents of the registers themselves.

Yes, because any instruction that affects A, flags, B, C, D, E, H or L will also work on an alternate register.

Confusing? Not really. It's simply this: there's 2 for each of AF / BC /DE / HL. But for any of those, only 1 is active at any time. Which one, is selected (flipped back & forth) whenever you execute an exchange instruction. Everyting that works on AF-HL, affects the currently selected ones, the currently non-selected ones are simply 'invisible' / unreachable.

Internally in the Z80, there's probably some flip-flops that decide which set is active (one for AF vs. AF', one for BC-HL vs. BC'-HL'). And the exchange instructions simply flip those 'pointers'. Apart from that, these register sets are the same (and other than following a program's flow, you can't tell 'm apart).

Like Andy said, ZEXALL (and ZEXDOC, for testing documented instructions only) is what you're looking for. Just make it fit onto your 'hardware', then sit back. ;)
Rink
Posts: 165
Joined: Wed Jun 27, 2012 5:48 pm

Re: Testing Z80 Emulation...

Post by Rink »

I had a quick look at ZEXDOC but because I'm not building a ZX emulator, I don't think I have any suitable output that it can look at. I need to spend a bit more time checking that though when I'm not at work.

I'm a bit happier with the alternate registers thing now. Cheers mate.
Post Reply