News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Z80 instructions - subset implemented by 464 rom?

Started by aidano, 15:30, 26 November 22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aidano

I'm trying to find out what subset of the full z80 instruction set is used by the CPC 464 rom. Is it documented anywhere?

For context, I'm writing an emulator and am partially into the laborious stage of implementing the instruction set. Doing every single instruction up front will probably destroy me :) so my strategy is to take a loaded 464 rom, and begin interpreting each instruction that's not currently understood by my runtime. I realize that knowing the answer won't change the amount of work, but I would like to know what's ahead of me for this phase of the project.

Bryce


aidano

Thanks @Bryce - are the instructions enumerated in there anywhere? I took a quick look through but didn't see it, but could just have missed something obvious.

This may not exist in the from I'm seeking (outside of other CPC emulator source code which has chosen a similar path to only implement a subset of instructions, but I'm looking to completely avoid looking at any other emulator implementation).

Gryzor


Bryce



Gryzor

Quote from: Bryce on 18:41, 26 November 22
Quote from: Gryzor on 18:19, 26 November 22I think you mean @Bryce  🙂

So we're not interchangeable?? :o

Bryce.

You do the hardware, I'll do the (messing up of) the forum database. 

Gryzor

Quote from: aidano on 18:43, 26 November 22
Quote from: Gryzor on 18:19, 26 November 22I think you mean @Bryce  🙂
Oops! Sorry for the summons!
No worries, I actually meant to read your thread and the quote notification prompted me to finally open it 🙂

Bryce

Quote from: Gryzor on 18:48, 26 November 22
Quote from: Bryce on 18:41, 26 November 22
Quote from: Gryzor on 18:19, 26 November 22I think you mean @Bryce  🙂

So we're not interchangeable?? :o

Bryce.

You do the hardware, I'll do the (messing up of) the forum database.

A small (evil) part of me wants to see you soldering an 0201 resistor without messing it up.

Bryce.

Gryzor

I'll need new glasses for that one. I can do a 0603 though -oh you said without messing it up? That's unfair. I'll give it a try when you fix the quotes query that randomly makes the CPU spike for a minute or so. 

Prodatron

Back to topic:

Quote from: aidano on 15:30, 26 November 22I'm trying to find out what subset of the full z80 instruction set is used by the CPC 464 rom. Is it documented anywhere?

For context, I'm writing an emulator and am partially into the laborious stage of implementing the instruction set. Doing every single instruction up front will probably destroy me :) so my strategy is to take a loaded 464 rom, and begin interpreting each instruction that's not currently understood by my runtime. I realize that knowing the answer won't change the amount of work, but I would like to know what's ahead of me for this phase of the project.
I think there is no clean, sorted list of the used Z80 instructions in the 464 ROM.
Maybe a ROM listing may help you:

https://www.cpcwiki.eu/index.php/ROM-Listing_CPC_464/664/6128

It starts at page 217, where the complete ROM is disassembled (sorry, comments in german, but I guess just the instructions are the thing you are looking for).

I think they used nearly all "official" Z80 instructions. What they didn't use are stuff like IXL, IXH, IYL, IYH or OUT (C),0
IIRC the 2nd register set is only used during interrupt handling.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

BSC

Quote from: aidano on 15:30, 26 November 22For context, I'm writing an emulator and am partially into the laborious stage of implementing the instruction set. Doing every single instruction up front will probably destroy me
Honestly, I don't think you should spend (waste) your time on finding that subset. Eventually you will have to implement the whole set of instructions anyway, otherwise software will randomly work or not work. Also there are already working implementations of a Z80 emulation in a lot of languages. Unless you really want to roll your own, you could resort to one of those. But the time you already spent on researching that ROM issue could have been spent on implementing a not so tiny part of the instruction set, I suppose :) Finally, to add to Prodatron's comment, which I agree with, the lower ROM alone would not give you a running CPC, for that the Basic ROM also needs to be present and I am pretty sure that the vast majority of the instruction set is used in both ROMs combined.
** My SID player/tracker AYAY Kaeppttn! on github **  Some CPC music and experiments ** Other music ** More music on scenestream (former nectarine) ** Some shaders ** Some Soundtrakker tunes ** Some tunes in Javascript

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

aidano

Quote from: Prodatron on 12:01, 27 November 22Back to topic:

Quote from: aidano on 15:30, 26 November 22I'm trying to find out what subset of the full z80 instruction set is used by the CPC 464 rom. Is it documented anywhere?

For context, I'm writing an emulator and am partially into the laborious stage of implementing the instruction set. Doing every single instruction up front will probably destroy me :) so my strategy is to take a loaded 464 rom, and begin interpreting each instruction that's not currently understood by my runtime. I realize that knowing the answer won't change the amount of work, but I would like to know what's ahead of me for this phase of the project.
I think there is no clean, sorted list of the used Z80 instructions in the 464 ROM.
Maybe a ROM listing may help you:

https://www.cpcwiki.eu/index.php/ROM-Listing_CPC_464/664/6128

It starts at page 217, where the complete ROM is disassembled (sorry, comments in german, but I guess just the instructions are the thing you are looking for).

I think they used nearly all "official" Z80 instructions. What they didn't use are stuff like IXL, IXH, IYL, IYH or OUT (C),0
IIRC the 2nd register set is only used during interrupt handling.
Thanks, that's helpful to at least follow along as my runtime proceeds through the code. Clearly I was off-base in my guess that some non-trivial number of instructions weren't used. What a useful little chip the Z80 was :)

aidano

Quote from: BSC on 12:23, 27 November 22
Quote from: aidano on 15:30, 26 November 22For context, I'm writing an emulator and am partially into the laborious stage of implementing the instruction set. Doing every single instruction up front will probably destroy me
Honestly, I don't think you should spend (waste) your time on finding that subset. Eventually you will have to implement the whole set of instructions anyway, otherwise software will randomly work or not work. Also there are already working implementations of a Z80 emulation in a lot of languages. Unless you really want to roll your own, you could resort to one of those. But the time you already spent on researching that ROM issue could have been spent on implementing a not so tiny part of the instruction set, I suppose :) Finally, to add to Prodatron's comment, which I agree with, the lower ROM alone would not give you a running CPC, for that the Basic ROM also needs to be present and I am pretty sure that the vast majority of the instruction set is used in both ROMs combined.
Thanks, makes sense. I was under the false assumption that there would be some kind of 80/20 rule at play here with the instructions that the firmware and most games would use.

And yes, I could for sure look for existing implementations, but my goal is an exploration of writing an emulator/learning a new language, while looking out for opportunities to see tangible progress.

andycadley

If you want to try and get away with a subset implementation, just have the whole thing stop on hitting an instruction you haven't implented. Then add that and see how much further it goes. Like others say though, it'll probably hit the majority of them.

aidano

Quote from: andycadley on 20:15, 27 November 22If you want to try and get away with a subset implementation, just have the whole thing stop on hitting an instruction you haven't implented. Then add that and see how much further it goes. Like others say though, it'll probably hit the majority of them.
That's precisely what I'm doing :)

Powered by SMFPacks Menu Editor Mod