z80 opcode documentation.
Moderator: MaxCoderz Staff
- thegamefreak0134
- Extreme Poster
- Posts: 455
- Joined: Mon 23 Jan, 2006 10:09 pm
- Location: In front of a Computer, coding
- Contact:
z80 opcode documentation.
I am writing a GB emulator. Since the GB and GBC both use a variant of the z80 processor, I've been using a lot of different things. I'm bascally going to code every single instruction into the thing before I try to write a display routine and run anything. As I was going down the list however, I found quite a few (mainly the CB prefixed instructions) that I could not figure out the useage for. There was also a lot of missing info on flags. The docs I have mention which flags are affected, but usually fail to specify how. And yes, I realize that the GB only has 4 flags, whereas a typical z80 processor should have 8, but we won't go there.
Can someone provide me with some much more complete documentation on the z80 instruction set? I have lots of info on how the GB itself actually displays the screen based on the registers and such, but I can't seem to get the emulation of the core down at all. Perhaps the writers of VTI and PTI could help me out? Once I have the processor running, the rest should be relatively simple.
-gamefreak
Can someone provide me with some much more complete documentation on the z80 instruction set? I have lots of info on how the GB itself actually displays the screen based on the registers and such, but I can't seem to get the emulation of the core down at all. Perhaps the writers of VTI and PTI could help me out? Once I have the processor running, the rest should be relatively simple.
-gamefreak
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
As far as I'm aware, the "Sharp80" is not entirely compatible and uses some different opcodes to the regular Z80. Bearing that in mind, I have lots of nice tables for the Z80 from this site.
Also, take a look at the SMS Power! Z80 section - they have the original user manual up for download.
Also, take a look at the SMS Power! Z80 section - they have the original user manual up for download.
-
- MCF Legend
- Posts: 1601
- Joined: Mon 20 Dec, 2004 8:45 am
- Location: Budapest, Absurdistan
- Contact:
I wrote up a reference at WikiTI, but it’s really just a reference. All the flags, including all the ‘undocumented’ behaviour is covered, but I have no idea how much of that can be applied to this variant.
- thegamefreak0134
- Extreme Poster
- Posts: 455
- Joined: Mon 23 Jan, 2006 10:09 pm
- Location: In front of a Computer, coding
- Contact:
Wow. The references y'all gave are a lot to swim through, but it's usefull. Thanks! I've finally started to work on the finer details of the "core" if you will, and it will take a few weeks but it should work out alright.
I do have one question though. On some of the documentation there are jp and call commands that have a "$+2" following them, and have no bytes listed in the opcode as arguments. This basically means to relative jump to the one byte address following the opcode and to directly jump to the two byte address (depending on the command of course) yes?
Also, two questions concerning 16-bit numbers. In what order are 16-bit numbers stored on the stack, and in what order will they appear in memory? I want to say they get "pushed" high, then low, but get "written" low then high, but I'm not quite sure. Confirmation on this?
-gamefreak
I do have one question though. On some of the documentation there are jp and call commands that have a "$+2" following them, and have no bytes listed in the opcode as arguments. This basically means to relative jump to the one byte address following the opcode and to directly jump to the two byte address (depending on the command of course) yes?
Also, two questions concerning 16-bit numbers. In what order are 16-bit numbers stored on the stack, and in what order will they appear in memory? I want to say they get "pushed" high, then low, but get "written" low then high, but I'm not quite sure. Confirmation on this?
-gamefreak
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- MCF Legend
- Posts: 1601
- Joined: Mon 20 Dec, 2004 8:45 am
- Location: Budapest, Absurdistan
- Contact:
The Z80 is little-endian, which means that all instructions involving 16-bit memory operations (ld, push, pop, call, ret, rst) treat the numbers as ‘LSB first’.thegamefreak0134 wrote:Also, two questions concerning 16-bit numbers. In what order are 16-bit numbers stored on the stack, and in what order will they appear in memory? I want to say they get "pushed" high, then low, but get "written" low then high, but I'm not quite sure. Confirmation on this?
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
The Z80 Family CPU User Manual file should be of interest. It describes things fairly thoroughly.
- thegamefreak0134
- Extreme Poster
- Posts: 455
- Joined: Mon 23 Jan, 2006 10:09 pm
- Location: In front of a Computer, coding
- Contact:
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
You mean there are sickos out there who store the little end of their bytes first?!!? Prepare the invasion immidiately!
The $0150 thing is an honest typo. Will be interesting seeing how well the calc can be emulated.
The $0150 thing is an honest typo. Will be interesting seeing how well the calc can be emulated.
My diet consists of nails, code-stealers, and HP fans.
Projects:
Robot War [TI-82, TI Flash App]
Sonic the Hedgehog [Multiplatform]
Projects:
Robot War [TI-82, TI Flash App]
Sonic the Hedgehog [Multiplatform]